Getting the mail without the attachment I am using microsoft graph sendMail. I need to add an attachment at the same time. I added the attachment Object inside message of request body. But received the mail without the attaachment. i was following : https://docs.microsoft.com/en-us/graph/api/resources/fileattachment?view=graph-rest-1.0 PFB my code.
function sendAttachment(accessToken) {
const attachments = [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"contentBytes": "",
"name": "example.jpg"
}
];
var message=
{ subject: 'It\'s working ',
body:
{ contentType: 'Text',
content: 'Sending mail using microsoft graph and Outh2.0' },
toRecipients: [ { emailAddress: { address: '' } } ],
ccRecipients: [ { emailAddress: { address: '' } } ]
};
message["attachments"] = attachments;
var options = {
method: 'POST',
url: 'https://graph.microsoft.com/v1.0/users/xyz@xyz.com/sendMail',
headers:
{ 'Cache-Control': 'no-cache',
Authorization: 'Bearer '+ accessToken,
'Content-Type': 'application/json' },
body:JSON.stringify({
"message": message,
"SaveToSentItems": "false"
}),
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log("--attachment--");
});
}
what am i missing here ??