views:

332

answers:

1

I'm creating a program to automatically generate reports from incoming email attachments and it is almost complete save for one area. The incoming emails are automatically filtered into folders which differentiate which client and server they originate from. I can't figure out how to get the path of the folder from the email Item.

I'm using the NewMailEx event to call the method below and this.AppNamespace and this.ReportFolder are confirmed to be instantiated properly.

void AppClass_NewMailEx(string EntryIDCollection)
{
    Outlook.MailItem Item = (Outlook.MailItem)this.AppNamespace.GetItemFromID(EntryIDCollection, this.ReportFolder.StoreID);
    string FolderName = ""; //How do I get this?
}

The MSDN on MailItem is here. Am I missing something or approaching this the incorrect way?

+2  A: 

I think there's a Parent that you can check - it should return a MAPIFolder that you can check the Name of.

Mark Brackett
There is a `Parent` property however the documentation is basically non-existent on what it actually returns. I'll give it a try here shortly.
Jake Wharton
Worked beautifully, thank you very much. Also produced another nice issue I haven't been able to resolve: http://stackoverflow.com/questions/1772406/how-can-i-get-outlook-interop-newmailex-to-fire-on-subfolders-of-the-inbox
Jake Wharton