开发者

Get the target MAPI Folder and EntryID of a MailItem after applying Outlook rules

I'm creating an Add-In for Outlook 2007, which handles NewMailEx event and gives the StoreID of the MAPI Folder and EntryID of the incoming email in that folder, after all the Outlook rules are applied to it. The Add-In will track the email later, using the GetItemFromId() method of System.NameSpace class. I tried searching with the unique PR_SEARCH_KEY of the mailitem, but it was taking too much time unnecessarily scanning all the folders a开发者_开发知识库nd sub-folders. I need a way to remember an email, and not searching it again.


When handling NewMailEx you get EntryIDCollection containing a comma separated string. These look like GUIDS. You need to save that string somewhere (or just the ID you wish to save) and then you can get the item(s) using

Outlook.MailItem mi = thisAddIn.Application.Session.GetItemFromID(id, Type.Missing) as Outlook.MailItem

Where ID is the single ID for the item you want. You'll have to call this once for each item in your collection. It doesn't matter where it ends up after the rules are applied. the ID will always be the same.

@rotard To get the contact folder just use

public string GetFolderFullName(Outlook.ContactItem ci) 
{
     Outlook.MAPIFolder mf = ci.Parent;
     string path = mf.FolderPath;
     return path;
 } 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜