Search code examples
outlookadd-in

Office.Interop.Outlook.MailItem how to get path to local file


Is there any option to get path to local msg/eml file? For example: User opens file from local drive. My inspector wrapper should detect is this file located on a specific folder. Have tried MAPIFolder but it's returns only outlook specific locations like Inbox.

item = (TOutlookItem)Inspector.CurrentItem;
var mail = item as MailItem;
var folder = mail.Parent as MAPIFolder;
var path = folder.FullFolderPath;

Solution

  • There is no way to do that - Outlook always creates a temporary message in the default store and imports the EML / MSG file prior to displaying the message.

    The best you can do is check that MailItem.EmtryID == "" and MailItem.Saved == true to detect such a message.