我正在从 Outlook 帐户检索邮件。我正在尝试从这些消息中获取内联文件和附件。
$graph = new Graph();
$graph->setAccessToken($this->getAccessToken());
$messageQueryParams = array (
"\$select" => "subject,receivedDateTime,from,sentDateTime,body,toRecipients,sender,uniqueBody,ccRecipients,bccRecipients,attachments",
"\$orderby" => "receivedDateTime DESC",
"\$top" => "200"
);
$url = '/me/mailfolders/' . $folder . '/messages/delta';
$url_combiner = '?';
$getMessagesUrl = $url . $url_combiner . http_build_query($messageQueryParams);
$response = $graph->createRequest('GET', $getMessagesUrl)->execute();
$messages = $response->getResponseAsObject( \Microsoft\Graph\Model\Message::class );
foreach($messages as $msg) {
echo $msg->getHasAttachments();
}
此代码为 $msg->getHasAttachments(); 返回“null”;我希望它返回真或假。
我从这个文件夹下载的邮件既有内联附件也有邮件附件,所以我正在寻找两者的解决方案。
(非常感谢指向 MS Graph PHP SDK 文档中特定点的响应。)