Email Sender using CDO and Gmail with AutoHotkey

Sending emails through Gmail (and other vendors) is easy with AutoHotkey!  Check out the video and source script below.

Email Sender using CDO and GMAIL with AutoHotkey

 

Here’s the source code for the Email Sender using CDO

#SingleInstance,Force ;run only once
SetBatchLines,-1
IniRead, CDO_Password ,Auth.ini,CDO, Gmail_Password
;~ https://autohotkey.com/board/topic/36522-cdo-com-email-delivery/</code>

Important:={smtpserver: "smtp.gmail.com" ;"host157.hostmonster.com" ; specify your SMTP server
,smtpserverport: 465 ;587 465 ;110 ; 25
,smtpusessl: True ;For hostmonster it must be true
,sendusing: 2 ; cdoSendUsingPort
,smtpauthenticate: 1 ; cdoBasic
,sendusername: "[email protected]" ;"[email protected]" ;Login UserName for the SMTP Server
,sendpassword: CDO_Password ;You have to create a special "App password" in gmail and use it here. https://the-automator.com/gmail_App_Password
,smtpconnectiontimeout: 60} ;Login Password
;*************Per message******************************************
HTML=This is in html. Check out the-Automator for some cool tips!

pmsg:=ComObjCreate("CDO.Message")
pmsg.From:="[email protected]"
pmsg.To:="[email protected];[email protected]"
pmsg.BCC:=
pmsg.CC:=
pmsg.Subject:="Send via CDO and AutoHotkey"
;~ pmsg.HtmlBody:=HTML ;This would be your content in an HTML format.
pmsg.TextBody := "This is the body of a plain text message" ;if you want to send plain text

Fields:={smtpserver:Important.smtpserver,smtpserverport:Important.smtpserverport,smtpusessl:Important.smtpusessl,sendusing:Important.sendusing,smtpauthenticate:Important.smtpauthenticate,sendusername:Important.sendusername,sendpassword:Important.sendpassword,smtpconnectiontimeout:Important.smtpconnectiontimeout}
pfld:=pmsg.Configuration.Fields
For Field,Value in fields
pfld.Item("http://schemas.microsoft.com/cdo/configuration/" Field):=Value
pfld.Update()

;********************File Attachements***********************************
sAttach := "C:\AHK Studio\Projects\Companies.txt|C:\AHK Studio\Projects\AHK_LinkedIn.txt"
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
pmsg.AddAttachment(A_LoopField)
pmsg.Send()

 

Comments are closed.