简体   繁体   中英

Get MIME and/or EML Email Content/ format using Microsoft Graph API SDK .net Core

I have read the following article. How to get MIME content of Office365 mail using Microsoft Graph API?

Yes we can get the mime value using REST call. However, my requirement is getting the MIME using .net core Microsoft.Graph SDK.

I can easily get the Message using the following code in the shape of IMailFolderMessagesCollectionPage. But what I need is in the MIME shape/ EML

graphClient.Users[userEmailAddress].MailFolders[folderNameId].Messages.Request().GetAsync() 

However, I am unable to find any method in the Graph API SDK C# to get any MIME content. Any advices? Thanks.

I have tested in POSTMAN and Graph Explorer and I was able to get the MIME content in them as shown below.

在此处输入图片说明

Looks like the Content is not present in SDK yet but you can use the below code to get the MIME content.

var request = graphClient.Me.Messages["AAMkAGI0Mjk2NTQ5LTE4MjctNDE1Yy04Nzc0LWIxNzA0MDBkNDkwZABGAAAAAABAJhtsoNeXR49KeByGVNbsBwB0tR3-uC1cSqrKkE00IGLeAAAAAAEMAAB0tR3-uC1cSqrKkE00IGLeAADHJTf8AAA="].Request()
                        .GetHttpRequestMessage();

            request.RequestUri = new Uri(request.RequestUri.OriginalString + "/$value");
            var response = await graphClient.HttpProvider.SendAsync(request);

            var message = await response.Content.ReadAsStringAsync();

            Console.WriteLine(message);

You can see the content as below.

在此处输入图片说明

I have referred the code from here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM