如何使用GraphServiceClient Microsoft Graph API获取MimeContent

时间:2019-05-15 17:28:16

标签: c# graph

我想在Microsoft中使用GraphServiceClient获取电子邮件的MimeContent。图1.15版。

我发现我们可以使用以下方式获得mime内容: HTTP GET / users / {id} / messages / {id} / $ value

但是如何在请求中翻译呢?

还有另一种方法或另一个NuGet软件包来获得此信息吗?

1 个答案:

答案 0 :(得分:1)

Workaround to get mime content from message-id
 using (HttpClient httpclient = new HttpClient())
            {                    
                httpclient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

                Uri requestEndpoint = new Uri("https://graph.microsoft.com/beta/me/messages/{id}/$value");

                string mimeResponse = await httpclient.GetStringAsync(requestEndpoint);

                byte[] emailData= System.Text.Encoding.UTF8.GetBytes(mimeResponse);

                Stream stream = new MemoryStream(emailData);
                //upload logic
            }