Add Email Headers for Outlook (MAPI) – VBScript


It is quite easy to add the email headers for SMTP message, but NOT that straight forward for Outlook. Below is the way and tested in Outlook 2010

  • Dim ToAddress
  • Dim MessageSubject
  • Dim MessageBody
  • Dim MessageAttachment
  • Dim ol, ns, newMail
  • ToAddress = “xxx@yahoo.com”
  • MessageSubject = “Subject-TEST xxx ”
  • MessageBody = “Message Body –xxx ”
  • MessageAttachment = “D:\abc\message_zdm.html”
  • Set ol = WScript.CreateObject(“Outlook.Application”)
  • Set ns = ol.getNamespace(“MAPI”)
  • ns.logon “whoami”,”mypassword”,true,false
  • Set newMail = ol.CreateItem(olMailItem)
  • newMail.Subject = MessageSubject
  • newMail.Body = MessageBody & vbCrLf
  • newMail.Attachments.Add MessageAttachment
  • Set pa=newMail.PropertyAccessor
  • pa.SetProperty “http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/X-IBE-Encrypted”, “class=SecureMail; version=3”
  • pa.SetProperty “http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/X-IBE-Encrypted-Agent”, “vendor=Voltage; product=Encryption; version=x.x.x”
  • ‘ validate the recipient, just in case…
  • Set myRecipient = ns.CreateRecipient(ToAddress)
  • myRecipient.Resolve
  • If Not myRecipient.Resolved Then
  • MsgBox “unknown recipient”
  • Else
  • newMail.Recipients.Add(myRecipient)
  • newMail.Send
  • End If
  • Set ol = Nothing

 

Reference: to be updated

Advertisements
This entry was posted in Exchange 2010. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s