html - Automate Mail merge in Excel VBA - Not sending multiple emails -
this automated mail merge pieced few different sites.
it's been altered many times make sure email sends html , includes default users signature.
after button click, window pops select range, email personalised depending on range selection.
sub emailattachmentrecipients() 'updateby extendoffice 20160506 dim xoutlook object dim xmailitem object dim xrg range dim xcell range dim xtxt string dim signature string dim xemail string dim xsubj string dim xmsg string dim integer dim k double ' create window select range xtxt = activewindow.rangeselection.address set xrg = application.inputbox("please select arresses list:", "water corporation mail merge", xtxt, , , , , 8) if xrg nothing exit sub = 1 xrg.rows.count set xoutlook = createobject("outlook.application") set xmailitem = xoutlook.createitem(0) xmsg = "<body style=font-size:11pt;font-family:verdana>" & sheet2.cells(4, 2) & " " & xrg.cells(i, 1) & ",</body>" & "<br>" xmsg = xmsg & "" & sheet2.cells(6, 2) & " " & sheet2.cells(6, 4) & " " & sheet2.cells(6, 6) & " " & "<br>" & "<br>" xmsg = xmsg & "" & sheet2.cells(8, 2) & " " & "<br>" & "<br>" xmsg = xmsg & "" & sheet2.cells(10, 2) & "" & "<br>" xemail = xrg.cells(i, 2) xmailitem .display .to = xemail .cc = "" .subject = "" & sheet2.cells(2, 2) & " " & xrg.cells(i, 3) & " - " & xrg.cells(i, 4) & "" .htmlbody = xmsg & .htmlbody .send end set xoutlook = nothing set xmailitem = nothing next end sub
i'm having trouble getting code send more 1 email, in select range of 5 rows , email client sends off 1 email.
does have direction lend?
thanks solving this!
it looks me though aren't putting compose email in loop.
for = 1 xrg.rows.count <<put email composing code here>> next
Comments
Post a Comment