Gmail sending email

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

Gmail sending email

21 Apr 2017, 18:58

I do not take credit for this code, I found it, I can't get it to work. Is it possible to make it work still?

I am currently using Version 1.1.25.01

The following is the source code:

Code: Select all

pmsg 						:= ComObjCreate("CDO.Message")
pmsg.From 					:= """from"" <@gmail.com>"
pmsg.To 					:= ""
pmsg.BCC 					:= ""   									; Blind Carbon Copy, Invisible for all, same syntax as CC
pmsg.CC 					:= ""										; [email protected], [email protected]
pmsg.Subject 					:= "See below"
;pmsg.TextBody 					:= ""
pmsg.HtmlBody 					:= "<html><head><title>Hello</title></head><body><table border='1'><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr><tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table> </body></html>"
;sAttach   					:= "" 										; can add multiple attachments, the delimiter is |
fields 						:= Object()
fields.smtpserver   				:= "smtp.gmail.com" 						; specify your SMTP server
fields.smtpserverport   			:= 465 										; 25
fields.smtpusessl      				:= True 									; False
fields.sendusing     				:= 2   										; cdoSendUsingPort
fields.smtpauthenticate 			:= 1   										; cdoBasic
fields.sendusername 				:= "@gmail.com"
fields.sendpassword 				:= ""
fields.smtpconnectiontimeout			:= 60
schema 						:= "http://schemas.microsoft.com/cdo/configuration/"
pfld 						:=  pmsg.Configuration.Fields
For field,value in fields
	pfld.Item(schema . field) 		:= value
pfld.Update()
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
	pmsg.AddAttachment(A_LoopField)
pmsg.Send()
return
Any explanation would be greatly appreciated. It's possible I didn't install Com right.

I got the source here: https://autohotkey.com/board/topic/2114 ... d-library/

Saved it in a file called com.ahk in the same directory as the script and used: #include filepath/com.ahk

I get this error when I run it:
Capture.PNG
Capture.PNG (39.86 KiB) Viewed 878 times
I've gone to the link: http://schemas.microsoft.com/cdo/configuration/ which doesnt work.

I'm really confused and would love help.

Thanks.
User avatar
AlleyArtwork
Posts: 44
Joined: 09 Jun 2015, 21:08

Re: Gmail sending email

21 Apr 2017, 20:30

I haven't tried it, but it looks like you're using google's SMTP server. If you don't have your own, you should try to look up the conditions of using their SMTP service.
Looks like you might need to specify your gmail address and password when using it.
https://www.digitalocean.com/community/ ... mtp-server
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

Re: Gmail sending email

21 Apr 2017, 20:48

I double checked and all of the settings in the script match the gmail smtp, also put in my pass and email and all other fields it asks me to fill out.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mikeyww, RussF and 391 guests