简体   繁体   中英

Updating an email's subject using Microsoft Graph in PHP

Here's my current code:

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();
}

I can run GET and POST requests which work, but I can't get PATCH to work this way. It continues to throw a 500 Internal Server Error . Any help is appreciated.

This is only supported on draft messages. From the documentation :

subject | String | The subject of the message. Updatable only if isDraft = true.

The following properties can only be updated in draft messages:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM