Use AutoHotKey to send Email via Gmail Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BarbiesScripts

Use AutoHotKey to send Email via Gmail

12 Oct 2017, 10:05

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
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Use AutoHotKey to send Email via Gmail

17 Oct 2017, 00:20

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.
Einfach nur ein toller Typ. :mrgreen:
dmatch
Posts: 49
Joined: 02 Oct 2013, 09:56

Re: Use AutoHotKey to send Email via Gmail

17 Oct 2017, 11:25

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).
BarbieS

Re: Use AutoHotKey to send Email via Gmail

17 Oct 2017, 11:58

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
dmatch
Posts: 49
Joined: 02 Oct 2013, 09:56

Re: Use AutoHotKey to send Email via Gmail

17 Oct 2017, 12:38

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 308 guests