How to store email attachment in another mail into .eml file using Graph api?
The contentBytes property is not directly available for .msg attachments because they are treated as itemAttachment rather than fileAttachment.
According to the documentation, for an item attachment that is a contact, event, or message, the raw contents returned is in MIME format not in ContentBytes.
This is by design and using Graph API we can't read the content bytes of an item Attachment.
But in my batch, we are receiving .msg files as an attachment along with other attachments in mail. It comes as Item attachment.
In case of File Attachment, we are able to read content bytes. But in case of Item attachment, how can we read content bytes?
We have to read content of email attachment which is attached in another email and store that attached email to .eml/msg file.
Suppose we have pdf, doc, msg attachments in email. We will be able to read content of pdf file and store it to .pdf file.
Similar way have to read email attachment (.msg) content also and store it as .eml file.