本文介绍了有没有办法使用Graph/office rest API创建具有特定日期(即创建/发送日期时间/更新日期时间)的邮件/(收件箱邮件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将EWS创建的旧SOAP消息转换为现代Graph API,之前由于发送MimeConent而成功创建了特定日期的消息,MimeConent已经包含With Dates示例:

           <?xml version="1.0" encoding="UTF-8"?>
            <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
               <soap:Header>
                  <t:RequestServerVersion Version="Exchange2016" />
                  <t:ExchangeImpersonation>
                     <t:ConnectingSID>
                        <t:PrincipalName>admin@xxx.com</t:PrincipalName>
                     </t:ConnectingSID>
                  </t:ExchangeImpersonation>
               </soap:Header>
               <soap:Body>
                  <CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" MessageDisposition="SaveOnly" SendMeetingInvitations="SendToNone">

                     <SavedItemFolderId>
                        <t:FolderId Id="AAMkAGM5MDIzODk0LTg2NmMtNDE3YS05M2YwLTBhZjgzZWQxODUxYQAuAAAAAAAX07OCLT/gQbX2qJJIVqojAQCdUXzQSXe1Tqh1KvhfGj3SAARQNYfhAAA=" ChangeKey="AQAAABYAAACdUXzQSXe1Tqh1KvhfGj3SAARSy240" />
                     </SavedItemFolderId>
                     <Items>
                        <t:Message>

                  //here MimeContent that has the specific dates....how to 
                       do that with REST ??????

                          <t:MimeContent CharacterSet="UTF-8">

  ......{BASE 64 ........} </t:MimeContent>

                           <t:ReminderIsSet>false</t:ReminderIsSet>
                           <t:ExtendedProperty>
                              <t:ExtendedFieldURI PropertyTag="0x0E07" PropertyType="Integer" />
                              <t:Value>4</t:Value>
                           </t:ExtendedProperty>
                        </t:Message>
                     </Items>
                  </CreateItem>
               </soap:Body>
            </soap:Envelope>

如果我使用Base64对MimeContent进行解码,将得到所描述的结果,这将创建特定的"日期",例如:createTime...

Date: Thu, 22 Jun 2017 11:36:01 +0000 (UTC)
From: valekseev@zzzzz.com
To: xxx@yyyy.zzzzz.com
Message-ID: <CAP-g2LzDoXpYeP+7PPs3LJYQtTkPe9ErqD-SgnbHKYZkkw5YuA@mail.gmail.com>
Subject: Test OutOfMemory
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_0_1169672575.1519724417079"

------=_Part_0_1169672575.1519724417079
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">Test OutOfMemory<br>
</div>
</body>
</html>

现在我正尝试用REST API做同样的事情(值不同,但没关系):

POST https://graph.microsoft.com/beta/me/messages
    Content-type: application/json

    {
        "subject":"Did you see last night's game?",
        "importance":"Low",
        "sentDateTime":"2016-12-23T07:29:58Z",
        "body":{
            "contentType":"HTML",
            "content":"They were <b>awesome</b>!"
        },
        "toRecipients":[
            {
                "emailAddress":{
                    "address":"AdeleV@contoso.onmicrosoft.com"
                }
            }
        ]

    , "singleValueExtendedProperties": [
          {
             "id":"Integer 0x0E07",
             "value":"4"
          }
        ]
     }
    }
但我得到的信息总是与sentDateTime的"Now"...为什么?

也许有一个选项可以用我的"内容"而不是正文来创建消息...

输出:

    "@odata.context":"https://graph.microsoft.com/beta/$metadata#users('ad787b4f-1fda-4523-8e48-ffedb7f4635f')/messages/$entity",
    "@odata.etag":"W/"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t"",
    "id":"AAMkAGRWAAAFSmKXAAA=",

     // I want here to be "2016-12-23T07:29:58Z" 
    "createdDateTime":"2018-03-02T19:14:13Z",  
    "lastModifiedDateTime":"2018-03-02T19:14:13Z",
    "changeKey":"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t",
    "categories":[

    ],
    "receivedDateTime": "2018-03-02T19:14:13Z",
    "sentDateTime": "2018-03-02T19:14:13Z",
    "hasAttachments":false,
    "internetMessageId":"<MWHPR130@MWHPR130.namprd13.prod.outlook.com>",
    "subject":"Did you see last night's game?".....,....
     ......
     ......

是否可以像我以前对EWS所做的那样,创建具有特定创建日期的消息...可能会有一些MAPI属性,如:

https://msdn.microsoft.com/en-us/library/office/cc765677.aspx

谢谢

推荐答案

否。你不能这么做。Store/Transport在创建和交付物品时在物品上标记日期。出于许多原因,保持该字段的准确性是有好处的,例如法律封存/遵从性等。

这篇关于有没有办法使用Graph/office rest API创建具有特定日期(即创建/发送日期时间/更新日期时间)的邮件/(收件箱邮件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 06:01