Share via

MS Graph - InternetMessageHeader error when sending mail with nested attachments

Shashwat Bisoyi 11 Reputation points
2021-10-06T09:43:05.167+00:00

First, I am getting the mails from the mailbox.
One mail contains an Outlook email attachment(.eml) as ItemAttachment and this mail contains 2 ItemAttchments (nested attachments).

var result = await graphServiceClient.me.MailFolders.Inbox.Messages[message.Id] .Attachments[parentmail.Attachments[0].Id].Request().Expand("microsoft.graph.itemattachment/item").GetAsync();
This retrieves the .eml mail with attachments. The Item property of result contains 40 internet message headers

Now if I send a new mail with the Item object of result as ItemAttachment in the new mail, it throws the error

Code: InvalidInternetMessageHeaderCollection
Message: Maximum number of headers in one message should be less than or equal to 5.
ClientRequestId: xxxxxx....

Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.