outlookvstooutlook-addinoffice-interopmapi

VSTO: Get long-term EntryID from Microsoft.Office.Interop.Outlook.Folder query


I'm wondering if it's possible to get the long-term entry id from a Microsoft.Office.Interop.Outlook.Folder query. I can successfully query the table, but the entry id is always the short-term entry id. As I understand it, the short-term entry id has the potential to change from session to session.

Here's my example code that -- additionally -- gets the sender's address as well as the base columns:

Table table = folder.GetTable();
table.Columns.Add("SenderEmailAddress");
while (!table.EndOfTable)
{
  Row row = table.GetNextRow();
  string entryId = row["EntryID"].ToString();
  string sender = row["SenderEmailAddress"].ToString();
  ...
}

Is it possible to add an additional column, allowing me to query the long-term entry id? Thank you.


Solution

  • Yes, you will need to request the PR_LONGTERM_ENTRYID_FROM_TABLE MAPI property. Since it is not one of the OOM properties, you will need to specify its DASL name - "http://schemas.microsoft.com/mapi/proptag/0x66700102":

    table.Columns.Add("http://schemas.microsoft.com/mapi/proptag/0x66700102");
    

    See Columns.Add on MSDN for more details.