vba - Reply with To Recipient Names in Greeting and Body -
i created macro replies sender first name added greeting, adds text body, , adds signature in fonts want.
now want pull of names of recipients, assigning value them can place elsewhere in body of email. if not done, settle getting of names greeting, though preferred able move names around.
i can pull of names. need exclude names, such in cc line of original email. take names line , place them in body, means assigning them value.
here whole macro runs now. pulls names , adds them, including in cc of original email. puts in body , signature, main concern being able separate recipients ccs , being able place them elsewhere in body.
sub autoaddgreetingtoreply() dim omail mailitem dim oreply mailitem dim greettime string dim strbody string dim sigstring string dim signature string dim strgreetnameall string dim lastname string dim strgreetname string dim long select case application.activewindow.class case olinspector set omail = activeinspector.currentitem case olexplorer set omail = activeexplorer.selection.item(1) end select strbody = "<h3><b></b></h3>" & _ "<br><br><b></b>" & _ "please visit website view transactions.<br>" & _ "let me know if have problems.<br>" & _ "<br><br>strgreetname " & _ "<a href=""http://www.google.com"">questions</a>" & _ "<br><br>thank you" sigstring = environ("appdata") & _ "\microsoft\signatures\90 days.htm" if dir(sigstring) <> "" strgreetname = left$(omail.sendername, instr(1, omail.sendername, " ") - 1) lastname = right(omail.sendername, len(omail.sendername) - instr(1, omail.sendername, " ")) if dir(sigstring) <> "" signature = getboiler(sigstring) else signature = "" end if set oreply = omail.replyall select case application.activewindow.class case olinspector set omail = activeinspector.currentitem case olexplorer set omail = activeexplorer.selection.item(1) end select oreply = 1 .recipients.count debug.print .recipients(i) strgreetname = left(.recipients(i), instr(1, .recipients(i), " ") - 1) strgreetnameall = strgreetnameall & strgreetname & ", " next debug.print strgreetname strgreetnameall = left(strgreetnameall, len(strgreetnameall) - 2) debug.print strgreetname .htmlbody = "<font face=calibri>dear " & strgreetnameall & "," & strbody & "<br>" & signature .display end end if end sub
the next piece of code believe should pull items separately, not whole group of recipients.
dim r outlook.recipient dim dim strto string, strcc string set recipients = oresponse.recipients = 1 recipients.count set r = recipients.item(i) debug.print r.name, r.type if r.type = olcc strcc = r.name & ", " & strcc else strto = r.name & ", " & strto end if next
here whole macro everything:
sub autoaddgreetingtoreply() dim omail mailitem dim oreply mailitem dim oresponse mailitem dim greettime string dim strbody string dim sigstring string dim signature string dim strgreetnameall string dim lastname string dim strgreetname string dim r outlook.recipient dim dim strto string, strcc string select case application.activewindow.class case olinspector set omail = activeinspector.currentitem case olexplorer set omail = activeexplorer.selection.item(1) end select sigstring = environ("appdata") & _ "\microsoft\signatures\90 days.htm" if dir(sigstring) <> "" strgreetname1 = left$(omail.sendername, instr(1, omail.sendername, " ") - 1) lastname = right(omail.sendername, len(omail.sendername) - instr(1, omail.sendername, " ")) if dir(sigstring) <> "" signature = getboiler(sigstring) else signature = "" end if set oreply = omail.replyall select case application.activewindow.class case olinspector set omail = activeinspector.currentitem case olexplorer set omail = activeexplorer.selection.item(1) end select oreply set recipients = oresponse.recipients = 1 recipients.count set r = recipients.item(i) debug.print r.name, r.type if r.type = olcc strcc = r.name & ", " & strcc else strto = r.name & ", " & strto end if next debug.print strgreetnameall strgreetnameall = left(strgreetnameall, len(strgreetnameall) - 2) debug.print strgreetnameall .htmlbody = "<font face=calibri>dear " & strto & strbody & "<br>" & signature .display end end if end sub
Comments
Post a Comment