espo
espo

Reputation: 67

Saving Graph Message into .MSG or .EML file

I am working on using MS Graph

https://graph.microsoft.com/v1.0/me/mailFolders/{folderID}/messages/{messageID}

to extract email messages. I have a requirement to save the email (message, attachments, etc) into a .MSG or .EML format.

I am having trouble finding anything that can help me do this. Any ideas? I know I can get the MIME value but not sure if that is enough or I need to do more.

Upvotes: 2

Views: 3372

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

You won't be able to save a Message in the MSG file format as this is an Office file format (Compound Binary format https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b)

For EML yes all you need is the MIMEContent

GET /users/{id}/messages/{id}/$value

And save that as a file with .eml extension

That said the MIME content of the message doesn't provide full fidelity on the Message as it won't include any extended MAPI properties. But this is generally only important for Mail Migration and Backup type applications for general use EML should be fine

Upvotes: 3

Related Questions