vba - Run Script to Append Subject and Body of Email -
i [attempting to] learn how write script in outlook when category set on email:
- append subject " proj=5"
- append body 10 lines of text
- send email.
my goal mark email category , forward email our ticketing system.
i'm not having luck samples have found.
samples (url) have tried (copied code , updated relevant fields):
- append subject " proj=5"
mailitem.subject property
returns string indicating outlook item. read/write.
item.subject = "proj=5" & item.subject
- append body 10 lines of text
example
dim olbody string olbody = "<html><body><p>append body 10 lines of text</p>" & vbnewline & vbnewline & _ "<p>append body 10 lines of text</p></html></body>" & vbnewline olforward.htmlbody = olbody & vbcrlf & olforward.htmlbody
- send / forward email
example
'// set olforward = item.forward '// add recipent olforward.recipients.add "email@domain.com" '// send or use .dispaly olforward.send
run script rule
to use rule wizard, macro has have expected parameter:
example
public sub itemforward(item outlook.mailitem) end sub
helpful article in msdn outlook 2010 vba
complete code test on outlook 2010 vba
please make sure references set run action script (tools > references)
option explicit '// run action script public sub itemforward(item outlook.mailitem) dim olapp outlook.application dim olforward mailitem dim olbody string set olapp = createobject("outlook.application") '// append subject item.subject = "proj=5 " & item.subject item.save set olforward = item.forward '// add recipent olforward.recipients.add "test@mail.com" olbody = "<html><body><p>append body 10 lines of text</p>" & vbnewline & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p>" & vbnewline & _ "<p>append body 10 lines of text</p></html></body>" & vbnewline '// forward email olforward.htmlbody = olbody & vbcrlf & olforward.htmlbody '// send or use .dispaly olforward.send set olapp = nothing set olforward = nothing end sub
Comments
Post a Comment