Is it possible to retrieve the RFC 2822 (or any) headers from an email with the Outlook/Office 365 REST API?

UPDATE: The InternetMessageHeaders property was added to the beta endpoint of the Outlook API, so you can get this without using the extended property stuff. You do have to request the property explicitly via $select though. Something like:

GET https://outlook.office.com/api/beta/me/mailfolders/inbox/messages?
$select=Subject,InternetMessageHeaders

For Graph: The property also exists on messages in the beta endpoint for Graph, so you can do:

GET https://graph.microsoft.com/beta/me/mailfolders/inbox/messages?
    $select=subject,internetMessageHeaders

For non-beta endpoints: The API doesn’t directly provide access. However, you can access the PidTagTransportMessageHeaders MAPI property using the Extended Property API.

From the first link, we see that the property ID for PidTagTransportMessageHeaders is 0x7D, and the type is String. So the $expand parameter of your GET would look like:

$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')

NOTE: This is only applicable for the Outlook endpoint (https://outlook.office.com). For Graph, see the answer from madsheep

Putting that together with a GET for a specific message, your request might look like:

GET https://outlook.office.com/api/v2.0/me/messages/{message-id}?
$select=Subject,SingleValueExtendedProperties
&$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String 0x7D')

Leave a Comment