Page 1 of 1

Use AutoHotKey to send Email via Gmail

Posted: 12 Oct 2017, 10:05
by BarbiesScripts
Hi

There are countless threads on this very topic, however none that I found worked (they used to in the past) and the error is related to CD0 Specified protocol not known. I would post the img but IMG is turned off for me, you can view it here by the post hamncheese https://autohotkey.com/board/topic/6081 ... k-l/page-5

For example, these solutions also no longer work

https://autohotkey.com/board/topic/8116 ... -gmailcom/

So after spending days trying solution after solution I decided it's time to read out on the forum. Maybe someone has something that will work for sending gmail directly from the script (in other words, if X is true send an email with gmail, no attachment needed and no cc/bcc) just plain text.

I hope someone can help.

Thank you

Re: Use AutoHotKey to send Email via Gmail

Posted: 12 Oct 2017, 15:27
by BoBo n-l-i
In case you won't be able to accomplish this on your own using COM ...
https://www.raymond.cc/blog/sending-ema ... ification/

Re: Use AutoHotKey to send Email via Gmail  Topic is solved

Posted: 17 Oct 2017, 00:20
by divanebaba
Hi.
My example could look a little bit tricky but after so many fails it worked fine.
The thread is in german language. If you have not visited school in Germany, you should have no problems to understand.

You only need Original Microsoft Powershell and you have to allow gmail to accept bit less secure login.
Please look E-Mail versenden ohne Zusatzprogramm.
Working script is discarded at due from 23 Jun 2017, 09:38.
All links to necessary additions are even discarded there too.

Bol ┼čanslar. :HeHe: :HeHe: :trollface: :trollface: Try even to translate this.

Re: Use AutoHotKey to send Email via Gmail

Posted: 17 Oct 2017, 11:25
by dmatch
I successfully used this script on windows 10:

https://autohotkey.com/board/topic/6081 ... ery-ahk-l/

I had to go into Gmail->My Account->Sign-In & Security->Allow less secure apps: ON (way at bottom of page).

Re: Use AutoHotKey to send Email via Gmail

Posted: 17 Oct 2017, 11:58
by BarbieS
dmatch wrote:I successfully used this script on windows 10:

https://autohotkey.com/board/topic/6081 ... ery-ahk-l/

I had to go into Gmail->My Account->Sign-In & Security->Allow less secure apps: ON (way at bottom of page).
That method no longer works in windows 10, thanks

Re: Use AutoHotKey to send Email via Gmail

Posted: 17 Oct 2017, 12:38
by dmatch
I just tried my implementation of it and it still works. Might be something in Win 10 settings causing different results or a win 10 update that I didn't get?

Here is what I actually ran as a script. Personal info not included:

Code: Select all

pmsg 			:= ComObjCreate("CDO.Message")
pmsg.From 		:= """Your From Name"" <Your gmail address>"
pmsg.To 		:= "[email protected]" ;Sent an email to myself as a test. Perhaps that's why it worked for me.
pmsg.BCC 		:= ""   ; Blind Carbon Copy, Invisable for all, same syntax as CC
pmsg.CC 		:= ; "[email protected], [email protected]"
pmsg.Subject 	:= "This is a test"

;You can use either Text or HTML body like
pmsg.TextBody 	:= "Testing"
;OR
;pmsg.HtmlBody := "<html><head><title>Hello</title></head><body><h2>Hello</h2><p>Testing!</p></body></html>"


sAttach   		:= ;"Path_Of_Attachment" ; 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 := "[email protected]"
fields.sendpassword := "YourPassword"
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()
I have not sent an email to anyone other than myself. Perhaps that is why it works for me. I also have not tested an attachment.

Re: Use AutoHotKey to send Email via Gmail

Posted: 17 Oct 2017, 14:10
by BarbiesScripts
that worked thank you!

Re: Use AutoHotKey to send Email via Gmail

Posted: 17 Oct 2017, 15:39
by dmatch
:thumbup: