-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathHTML_email_and_mailmerge.ahk
48 lines (42 loc) · 1.82 KB
/
HTML_email_and_mailmerge.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
40
41
42
43
44
45
46
47
48
var=
(
Email First_Name Last_Name
[email protected] Joe King
[email protected] Joseph GLines
)
;*********Use For loop over Var going line by line*********************
for i, row in Loopobj:=StrSplit(var,"`n") { ;Parse Var on each new line
IfEqual, i,1,continue ;Skip header row
;~ IfLessOrEqual,i,4382,continue
IfEqual, row,,continue ;Skip loop if blank
Menu , tray, tip, % i-1 " of " Loopobj.maxindex()-1 " : email is " StrSplit(row,"`t").1 ;Show progress on icon in system tray
;~ MsgBox % StrSplit(row,"`t").1 a_tab StrSplit(row,"`t").2 a_tab StrSplit(row,"`t").3 ;demonstrate values
MailItem := ComObjActive("Outlook.Application").CreateItem(0) ;Create a new MailItem object
MailItem.SendUsingAccount := MailItem.Application.Session.Accounts.Item["[email protected]"] ;Assign which account to use (can also use NameSpace)
MailItem.BodyFormat := 2 ; Outlook Constants: 1=Text 2=HTML 3=RTF
MailItem.TO :=StrSplit(row,"`t").1 ;"[email protected]" ; Seperate by ; if you want ot have multiple
;~ MailItem.CC :="[email protected]"
;~ MailItem.BCC :="[email protected]"
MailItem.Subject := "Example subject line"
MailItem.Attachments.Add("B:\the-automator\Webinar\Scripts\Outlook\AHK_Ball.jpg")
MailItem.Importance := 2 ;0=Low 1=normal 2=High
MailItem.DeferredDeliveryTime := "1/6/2012 10:40:00 AM"
MailItem.OriginatorDeliveryReportRequested := 1 ;Request a Delivery Reciept
MailItem.ReadReceiptRequested := 1 ;Request a Read Receipt
Name:=StrSplit(row,"`t").2
LastName:=StrSplit(row,"`t").3
Body=
( join comments
<HTML>
<p>Hi there %Name% %LastName%,</p> ;this is a comment
<p>Just saying hello</p>
</HTML>
)
;~ MsgBox % body
MailItem.HTMLBody :=Body
MailItem.Display ;
MsgBox pause
}
;~ mailItem.Close(0) ;Creates draft version in default folder
;~ MailItem.Send() ;Sends the email
Return