'MAPI Requests - Exchange Server (TCP/RPC) vs IMAP-Connection

I am currently developing an Outlook VSTO-AddIn using C#. I want to read certain attributes of each mailItem. (E.g. SenderName, SenderEmailAdress, etc. .. ) As far as I have understood I have understood- I have two option for achieving this:

  1. Accessing the Outlook object model
  2. Using a "Property Accessor Object" to read a MAPI property that belongs to a MailItem but that is not exposed in the Outlook object model. (https://docs.microsoft.com/de-de/office/vba/api/outlook.propertyaccessor)

A little Code Snippet for the property accessor: The mailItem is an object of the MailItemClass Class from the Microsoft.Office.Interop.Outlook namespace.

PropertyAccessor olPA = mailItem.PropertyAccessor;
SenderMailAddress = olPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1F001F");

I am encountering the following strange behavior: The results differ depending on whether I access the mailbox via IMAP or via TCP/RPC-Connections. Primarily when trying to access attributes of a mailItem sent by someone, whose Account has been removed. With an IMAP Connection the MAPI-Requests work fine, with TCP/RPC they don't.

Most resources I find on that topic are from 2009-2010, so I am unsure how they translate to the 2016-Version of Outlook.

Any hints that shed light on the difference between TCP/RPC in that case are greatly appreciated.



Solution 1:[1]

There is really no distinction between the two: PR_SENDER_EMAIL_ADDRESS gets retrieved by both MailItem.SenderEmailAddress and by MailItem.PropertyAccessor.GetProperty.

Do you actually see the PR_SENDER_EMAIL_ADDRESS property when you look at the item with OutlookSpy (I am its author) or MFCMAPI?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1