I'm retrieving Outlook email attachments using msgraph-sdk-php
and noticed that some emails have a .eml
attachments. When I get the email attachment by calling /users/{user_id}/messages/{message_id}/attachments'
I noticed that the response doesn't contain contentBytes
key.
for example:
[
{
"@odata.type": "#microsoft.graph.itemAttachment",
"id": "AAMkADlkMmfGrEBKuveYeL8nxW0=",
"lastModifiedDateTime": "2023-08-02T17:12:04Z",
"name": "single.eml",
"contentType": "message/rfc822",
"size": 23811,
"isInline": false
}
]
Non .eml attachments do contain the contentBytes
.
So i'm trying this endpoint me/messages/<Message-Id>/$value
which I got from this post
$cid = (new Graph())->setAccessToken($accessToken)
->createCollectionRequest("GET",
'/users/' . $userId . 'messages/' . $outlook_email->getId() . '/$value')
->setReturnType(\Microsoft\Graph\Model\Message::class)
->execute();
but I get this error
Client error: `GET https:\/\/graph.microsoft.com\/v1.0\/users\/636cb59d65489cmessages\/AAMkADlkMmIwZ_50gsmT9V9pNAAA=\/$value` resulted in a `403 Forbidden` response:\n{\"error\":{\"code\":\"Authorization_RequestDenied\",\"message\":\"Insufficient privileges to complete the operation.\",\"innerError\":{\"date\":\"2023-08-02T22:16:55\",\"request-id\":\"d3bcdef3-2c0d08121b5f\",\"client-request-id\":\"d3bcdef308121b5f\"}}}\n
I've search through Microsofts documentation but I can't figure out which permission to set so I can execute that call.
Which permission do I need? Or is there a different way for me to get the .eml
attachment content?