在PHP中使用Microsoft Graph更新电子邮件的主题

时间:2018-08-28 11:22:54

标签: php microsoft-graph outlook-restapi

这是我当前的代码:     

require_once '/pathtovendor/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
use Microsoft\Graph\Http\GraphRequest;

$access_token = "My valid access token";

$graph = new Graph();
$graph->setAccessToken($access_token);

$reply = array( "Comment" => "My reply" );
$message_id = "Valid message ID";

if($graph->createRequest("POST", "/me/messages/".$message_id."/reply")
      ->attachBody($reply)
      ->execute()){
        // I can get to this part OK. Message is replied to.

    //This code doesn't work
    $graph->createRequest("PATCH", "/me/messages/".$message_id)
      ->attachBody(array( "Subject" => "New Subject" ))
      ->execute();
}

我可以运行GETPOST个有效的请求,但无法让PATCH以此方式工作。它继续抛出500 Internal Server Error。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

仅草稿邮件支持此功能。来自documentation

  

subject |字串|   消息的主题。 仅在isDraft = true时才可更新。

以下属性只能在草稿消息中更新:

  • bccRecipients
  • body
  • ccRecipients
  • internetMessageId
  • replyTo
  • sender
  • subject
  • toRecipients
  • from