在 PHP 中使用 Microsoft Graph 更新电子邮件的主题
Updating an email's subject using Microsoft Graph in PHP
这是我当前的代码:
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();
}
我可以 运行 GET
和 POST
请求工作,但我不能 PATCH
这样工作。它继续抛出 500 Internal Server Error
。感谢任何帮助。
这仅在草稿邮件中受支持。来自 documentation:
subject
| String |
The subject of the message. Updatable only if isDraft = true.
以下属性只能在草稿消息中更新:
bccRecipients
body
ccRecipients
internetMessageId
replyTo
sender
subject
toRecipients
from
这是我当前的代码:
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();
}
我可以 运行 GET
和 POST
请求工作,但我不能 PATCH
这样工作。它继续抛出 500 Internal Server Error
。感谢任何帮助。
这仅在草稿邮件中受支持。来自 documentation:
subject
| String | The subject of the message. Updatable only if isDraft = true.
以下属性只能在草稿消息中更新:
bccRecipients
body
ccRecipients
internetMessageId
replyTo
sender
subject
toRecipients
from