Reputation: 117
I'm trying to include Microsoft Graph API mail subscription in a Javascript project with @microsoft/microsoft-graph-client
, I get an object response (body, subject, cc, to ...etc) and a Boolean hasAttachments: true
but the attachment url is nowhere to be found, is there a way to get these attachments ?
Upvotes: 0
Views: 1188
Reputation: 239
when you got the message try this url GET /me/messages/{id}/attachments/{id}
Upvotes: 2
Reputation: 2464
Ok i tried this Graph API call using Javascript code and it's working for me (get the .txt file):
const options = { authProvider, };
const client = Client.init(options);
let res = await client.api('/me/messages/AAMkAGRlNWM4Njk4LWY3NTYtNGE2MC05ZjQzLTg1YmM5YjIzNTRhMwBGAAAAAAA-L78mmzKFQ7FpvCcWkAziBwCUgufVfU8cSKxkYzIkrl81AAAAAAEMAACUgufVfU8cSKxkYzIkrl81AACABFjMAAA=/attachments/AAMkAGRlNWM4Njk4LWY3NTYtNGE2MC05ZjQzLTg1YmM5YjIzNTRhMwBGAAAAAAA-L78mmzKFQ7FpvCcWkAziBwCUgufVfU8cSKxkYzIkrl81AAAAAAEMAACUgufVfU8cSKxkYzIkrl81AACABFjMAAABEgAQAHhM4mZxBRNBqkVbYUzUcWA=').get();
and to convert the contentbytes and store it locally refer the related link - download attachments from mail using microsoft graph rest api as well.
Upvotes: 1