Importing an EML File into Outlook

I am trying to create a mail item in Outlook with old date and time, which looks some thing like an Inbox Mail Item which arrived long back. After some painful hours of searching and reading forums, 3rd party libraries, somehow, I got a solution to do this and would like to share it with you here.
Here you go!

Sub CreateMailFromEML()

Dim objPost As Outlook.PostItem
Dim objSafePost As Redemption.SafePostItem
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder
Const PR_ICON_INDEX = &H10800003


objNS = Application.GetNamespace(“MAPI”)
objInbox = objNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
objPost = objInbox.Items.Add(Outlook.OlItemType.olPostItem)
objSafePost = CreateObject(“Redemption.SafePostItem”)
objSafePost.Item = objPost
objSafePost.Import(“c:SampleEml.eml”, RedemptionSaveAsType.olRFC822)
objSafePost.MessageClass = “IPM.Note”
‘ remove IPM.Post icon
objSafePost.Fields(PR_ICON_INDEX) = String.Empty

Catch ex As Exception

MessageBox.Show(“Error: ” & ex.ToString)


objSafePost = Nothing
objPost = Nothing
objInbox = Nothing
objNS = Nothing

End Try

End Sub


  • We have to create an instance of Outlook.PostItem instead of Outlook.MailItem.
  • We can also do it using RDOMail which is much simpler than this. (I will discuss about this in separate post).

I have created the mail item with old date time stamps, attachments successfully. But, couldn’t reset the icon of the PostItem that is created. Searching for a solution to it . Will update it in this post once I got that.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s