Search This Blog

Thursday, December 23, 2010

How to Reference an Outlook Message (Mail Item) from the hard disk

this article demonstrates a quick code in VB.Net to reference an outlook mail item from the hard disk.

to run the code, first you need to open your MS Outlook, select a message in your inbox, then save it in your hard disk in the c:\ drive, and name it "Test", so the full path of the message item file is "c:\test.msg"

the following code will allow you to reference the message item using Outlook Object Library:


Dim oApp As New outlook.Application
Dim oItem As outlook.MailItem
oItem  = oApp.CreateItemFromTemplate("C:\test.msg")
MessageBox.Show(oItem .Body.ToString)


Note: do not forget to import "Microsoft.Office.Interop" Library