如何使用图SDK而不是API在请求中传递$ value以获取邮件的MIME内容 [英] How to pass $value in request to get mime content of mail using graph sdk not api

查看:50
本文介绍了如何使用图SDK而不是API在请求中传递$ value以获取邮件的MIME内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#中使用Graph SDK读取邮件,并且能够做到这一点.我想要我的邮件的Mime Content.我们如何使用SDK在请求中传递$ value.

I am using Graph SDK in C# to read mail messages and I am able to do that. I want Mime Content of my mail message. How do we pass $value in my request using SDK.

示例代码:

mails = await graphserviceclient
    .Me
    .Messages
    .Request()
    .Top(2)
    .GetAsync();

请让我知道如何在使用graphserviceclient的C#代码中传递$ value.

Please let me know how we can pass $value in C# code which uses graphserviceclient.

推荐答案

我们正在等待一些元数据更新,以便在SDK中更轻松地进行此操作.目前,获取MIME内容的解决方法如下:

We are waiting for some metadata updates to make this easier in the SDK. For the moment, the workaround for getting the MIME content looks something like this:

GraphServiceClient graphClient = new 
GraphServiceClient("https://graph.microsoft.com/beta/",authProvider);

var messageId = "...";
var request = graphClient.Me.Messages[messageId].Request()
            .GetHttpRequestMessage();

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

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

在不久的将来,您应该可以:

In the near future you should be able to do:

var aStream = await graphClient.Me.Messages[messageId].Content.Request().GetAsync();

这篇关于如何使用图SDK而不是API在请求中传递$ value以获取邮件的MIME内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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