question

WardH-0381 avatar image
0 Votes"
WardH-0381 asked WardH-0381 commented

Download email body and include the inline attachments

Hi
I am trying to write a C# app to download the message body in html and to include the inline attachment. Can I get ideally some c# to do that.

Failing that the method to handle it (steps) technique

Thanks
Ward

microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SrinivasaRaoDarnaMSFT-7657 avatar image
0 Votes"
SrinivasaRaoDarnaMSFT-7657 answered WardH-0381 commented

Hi @WardH-0381,

Take a look at this get-message-content, you can get the entire mail response including attachments.
The response is returned MIME, that body in plain text, body in html and also attachments with Base64 encoding.

 GraphServiceClient graphClient = new GraphServiceClient( authProvider );
 var stream = await graphClient.Me.Messages["{message-id}"].Content
     .Request()
     .GetAsync();

To get attachments of message, use below snippet.

 GraphServiceClient graphClient = new GraphServiceClient( authProvider );
 var stream = await graphClient.Me.Messages["{message-id}"].Attachments["{attachment-id}"].Content
     .Request()
     .GetAsync();

References:
Get MIME content
attachment-get

Hope this helps.

If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi

SrinivasaRaoDarna - MSFT

Thanks for your response ok I am probably misunderstanding this part.

Can you clarify how do I join the html I get from the body of the email to the inline attachment html.

Are you saying if I save as eml format I get the lot converted and then I don’t have to assemble the html myself?

Thanks
Ward

0 Votes 0 ·