Can I get RFC 2822 (or any) headers from email using the Outlook / Office 365 REST API?

The application I'm working on needs access to email headers, such as return-path , in-reply-to and references . Ideally, we would like to have access to all RFC 2822 email headers. Is this possible with the Outlook / Office 365 REST API? If not, is this possible with any API?

+3
source share
2 answers

UPDATE: The InternetMessageHeaders property has been added to the beta version of the Outlook API, so you can get this without using the advanced properties. You must explicitly request the property through $select . Sort of:

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

For a graph: The property also exists for messages at the beta endpoint for Graph, so you can:

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

For non-beta endpoints: the API does not directly provide access. However, you can access the PidTagTransportMessageHeaders MAPI property using the Extended Property API .

The first link shows that the property identifier for PidTagTransportMessageHeaders is 0x7D , and the type is String . Thus, the $expand parameter of your GET will look like this:

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

NOTE. This applies only to the Outlook endpoint ( https://outlook.office.com ). For a graph, see Reply from madsheep

By putting this together with GET for a specific message, your request may look like this:

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

For all poor souls lost in the insanties MS Graph api - the above answer no longer seems correct, as it will return the error "PropertyId is not a property name" - it seems the correct answer now:

 GET https://graph.microsoft.com/beta/me/messages/{message-id}? $select=Subject,SingleValueExtendedProperties& $expand=SingleValueExtendedProperties($filter=id eq 'String 0x7D') 

Here's how you get the message headers from the Outlook / Office 365 api REST diagram.

+4
source

Source: https://habr.com/ru/post/1215805/


All Articles