使用MSGraph ItemAttachment附加消息

时间:2017-04-25 20:17:53

标签: email-attachments microsoft-graph

我正在尝试实例化一个MSGraph ItemAttachment对象,以便将Message对象附加到另一个Message对象。我尝试过以下方法:

            var itemAttachment = new ItemAttachment
            {
                Item = message,
                //Size = ??,
                ContentType = "message/rfc822",
                Id = Guid.NewGuid().ToString(),
                IsInline = false,
                Name = "OrderMessage.msg",
                ODataType = message.ODataType,
                LastModifiedDateTime = DateTimeOffset.Now
            };
            errorMessage.Attachments.Add(itemAttachment);

Fiddler告诉我这会产生错误:"属性'项目'类型' Microsoft.OutlookServices.Attachment'中不存在。确保仅使用由类型定义的属性名称或将类型标记为打开类型。"

我也尝试过:

            var itemAttachment = new ItemAttachment
            {
                Item = message,
                //Size = ??,
                ContentType = "message/rfc822",
                Id = Guid.NewGuid().ToString(),
                IsInline = false,
                Name = "OrderMessage.msg",
                ODataType = "#microsoft.graph.itemAttachment",
                LastModifiedDateTime = DateTimeOffset.Now
            };
            errorMessage.Attachments.Add(itemAttachment);

Fiddler告诉我,这会产生错误:"注释' odata.context'被找到。此注释在当前位置无法识别或未被预期。"

我已尝试过其他几种变体,但没有任何效果。谁能告诉我这应该如何运作?

感谢。

1 个答案:

答案 0 :(得分:0)

我遇到类似Microsoft Graph Mail Attachment的问题---请参阅Microsoft.Graph send mail with attachment 因为这可能会有所帮助。添: