I use the Microsoft Graph SDK to send an email without problem, but when I add an attachment, this attachment doesn't appear in the mail sent. the attachements here are of type "Blob". and in PDF format. I've gone through several stackoverflow questions corresponding to this issue, but none resolved my issue that is why I'm asking my question here.
let graphMailAttachments = new Array<any>();
//attachments is an array of blob
attachments.forEach(async attachment => {
let file = await new Response(attachment).arrayBuffer();
graphMailAttachments.push({
"contentBytes": file,
"size": attachment.size,
"@odata.type" : "#microsoft.graph.fileAttachment",
"name": 'your-notes.pdf',
"id" : this.newGuid(),
})
});
subject = subject || "Your notes";
body = body || "Your notes";
let recipients = new Array<any>();
to.forEach(receiver => {
recipients.push({
emailAddress:{
address: receiver.email
}
})
});
let mail = {
message: {
subject: subject,
body: {
contentType: "Text",
content: body,
},
toRecipients: recipients,
attachments: graphMailAttachments,
},
SaveToSentItems : "true"
}
return this.graphClient.api('/me/sendMail').post(mail);
Am I doing something wrong ? The attachements just don't appear in the mail and it is kindof weird.