我正在使用Office 365邮件Microsoft Graph API,尝试按照Doc:
创建新邮件https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_post_messages
POST https://graph.microsoft.com/beta/me/messages
Content-type: application/json
{
"subject":"Did you see last night's game?",
"importance":"Low",
"body":{
"contentType":"HTML",
"content":"They were <b>awesome</b>!"
},
"toRecipients":[
{
"emailAddress":{
"address":"AdeleV@contoso.onmicrosoft.com"
}
}
]
}
{ 输出:
"@odata.context":"https://graph.microsoft.com/beta/$metadata#users('ad787b4f-1fda-4523-8e48-ffedb7f4635f')/messages/$entity",
"@odata.etag":"W/\"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t\"",
"id":"AAMkAGRWAAAFSmKXAAA=",
"createdDateTime":"2017-12-23T07:29:57Z",
"lastModifiedDateTime":"2017-12-23T07:29:58Z",
"changeKey":"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t",
"categories":[
],
"receivedDateTime":"2017-12-23T07:29:58Z",
"sentDateTime":"2017-12-23T07:29:58Z",
"hasAttachments":false,
"internetMessageId":"<MWHPR130@MWHPR130.namprd13.prod.outlook.com>",
"subject":"Did you see last night's game?",
"bodyPreview":"They were awesome!",
"importance":"low",
"parentFolderId":"AAMkAGRWAAAAAAEPAAA=",
"conversationId":"AAQkAGRVYAsRJrRdc_mWNaxU=",
"conversationIndex":"AQHTe7/VAniOJVgCxEmtF1z6ZY1rFQ==",
"isDeliveryReceiptRequested":false,
"isReadReceiptRequested":false,
"isRead":true,
"isDraft":true,
"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkAGRWAAAFSmKXAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification":"focused",
"unsubscribeData":[
],
我看到的输出是收件箱中创建的草稿消息。
我尝试发布“isDraft”:false,但结果不幸的是:(
基本上我的目的是“恢复”原始收件箱消息,这意味着在收件箱中创建它们而不发送....我用EWS做了,现在尝试转换成图形api
那么,是否可以选择创建邮件而不是草稿?
P.S:就像EWS一样 https://msdn.microsoft.com/en-us/library/ms527503(v=exchg.10).aspx非常感谢
答案 0 :(得分:4)
@David提到的最终解决方案是通过扩展属性:
根据:
和:
https://msdn.microsoft.com/en-us/office/office365/api/extended-properties-rest-operations
https://msdn.microsoft.com/en-us/library/ee218129(v=exchg.80).aspx
"singleValueExtendedProperties": [
{
"id":"Integer 0x0E07",
"value":"4"
}
]
}
答案 1 :(得分:2)
是。您必须通过属性标记0x0E07(整数)在创建时设置消息标志。从带有一些mod的EWS书籍 - “根据MSDN,MSGFLAG_UNSENT消息标志仅在首次保存消息(http://msdn2.microsoft.com/en-us/library/ms527629.aspx)之前是可读写的。之后,该标志是只读的。这意味着是如果要修改消息的消息标志,则必须在首次调用CreateItem(或REST等效项)时执行此操作。您无法在现有消息上清除此标志。“
答案 2 :(得分:0)
您还可以查看即时发送消息选项,这样就无需在某处创建消息然后发送消息。我们这样做,最后不会有任何悬挂的草稿。有关详细信息,请参阅此处:https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations?f=255&MSPPError=-2147217396#SendMessageOnTheFly