Please post your Web Driver questions in official Web Driver forum

Thursday, April 1, 2010

Reading Outlook Contents From VB Script

There are instances when an application involves mail delivery for certain app features. one way to automated this is to hook with Outlook and read content of mail (though I am not very comfortable with this approach anyways!)

####################################
'Get the Count of Items in Inbox
Set app = CreateObject("Outlook.Application")
Set nameSpace = app.GetNamespace("MAPI")
Set MyFolders = nameSpace.GetDefaultFolder(6)
MsgBox MyFolders.Items.Count


'Read unread items in Inbox
Set cols = MyFolders.Items

For each mail In cols
If mail.unread Then
MsgBox mail.subject
MsgBox mail.sendername
MsgBox mail.body
mail.unread=false
End If
Next
####################################
Fork me on GitHub