使用 Microsoft Graph API SDK .net Core 获取 MIME 和/或 EML 电子邮件内容/格式 [英] Get MIME and/or EML Email Content/ format using Microsoft Graph API SDK .net Core

查看:36
本文介绍了使用 Microsoft Graph API SDK .net Core 获取 MIME 和/或 EML 电子邮件内容/格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读以下文章.

Content 似乎还没有出现在 SDK 中,但您可以使用下面的代码来获取 MIME 内容.

 <代码>变种请求= graphClient.Me.Messages [" AAMkAGI0Mjk2NTQ5LTE4MjctNDE1Yy04Nzc0LWIxNzA0MDBkNDkwZABGAAAAAABAJhtsoNeXR49KeByGVNbsBwB0tR3-uC1cSqrKkE00IGLeAAAAAAEMAAB0tR3-uC1cSqrKkE00IGLeAADHJTf8AAA = QUOT].申请().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);

您可以看到如下内容.

我参考了 此处.

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.

这篇关于使用 Microsoft Graph API SDK .net Core 获取 MIME 和/或 EML 电子邮件内容/格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆