forked from Ixiko/AHK-libs-and-classes-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.ahk
39 lines (34 loc) · 1.22 KB
/
sendmail.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;this file is built from an example in the ahk forums and made into a function for including
;using #include c:\pathtofile\sendmail.ahk
SendMail(SMTPServer, SMTPPort, USESSL, Sender, Receiver, Subject, TextBody, Attachments="", SendUserName="username", SendPassword="password", SendUsing=2, SMTPAuthenticate=1, SMTPTimeout=60, ReplyTo=FALSE)
{
pmsg := ComObjCreate("CDO.Message")
pmsg.From := Sender
pmsg.ReplyTo := Sender
pmsg.To := Receiver
pmsg.BCC := ""
pmsg.CC := ""
pmsg.Subject := Subject
pmsg.TextBody := TextBody
sAttach := Attachments
fields := Object()
fields.smtpserver := SMTPServer ; specify your SMTP server
fields.smtpserverport := SMTPPort ; 25
fields.smtpusessl := USESSL ; False
fields.sendusing := SendUsing ; cdoSendUsingPort
fields.smtpauthenticate := SMTPAuthenticate ; cdoBasic
fields.sendusername := SendUserName ; if required
fields.sendpassword := SendPassword ; if required
fields.smtpconnectiontimeout := SMTPTimeout
schema := "http://schemas.microsoft.com/cdo/configuration/"
pfld := pmsg.Configuration.Fields
For field,value in fields
pfld.Item(schema . field) := value
pfld.Update()
;Add attachments
Loop, Parse, sAttach, |, %A_Space%%A_Tab%
pmsg.AddAttachment(A_LoopField)
;send the msg
pmsg.Send()
return
}