Graph API has a 4MB request limit so if I want to send an email with say a 10MB attachment I can't use the FileAttachment
type. As I understand it the recommended way to do this is with a ReferenceAttachment
which carries a link to a file that has been uploaded to OneDrive
(which does accept large payloads). However, when I do this I can see the ReferenceAttachment
in Sent Items (and can download it intact) but the attachment is not present at the destination (Gmail or Outlook).
I'm calling the beta
API using this URL:
https://graph.microsoft.com/beta/users/USERNAME/microsoft.graph.sendMail
The content posted is:
{
"saveToSentItems": true,
"message": {
"attachments": [
{
"sourceUrl": "https://100255-my.sharepoint.com/personal/USERNAME/Documents/sent-attachments/largefile.txt_6T7sHv5E",
"permission": "view",
"providerType": "oneDriveConsumer",
"name": "largefile.txt",
"contentType": "text/plain",
"@odata.type": "#microsoft.graph.referenceAttachment"
}
],
"subject": "Test E-Mail",
"toRecipients": [
{
"emailAddress": {
"address": "me@gmail.com"
}
}
]
}
}
How do I ensure that the email recipient gets the attachment?
EDIT:
When I use providerType: onDriveBusiness
I get a bit further. I get sent to gmail an unintelligible binary attachment (winmail.dat
or noname
) with the primary email and then a secondary email with a link asking me to open an account with Microsoft so that I can view the shared file. The subject of the second email is:
USERNAME wants to share the file largefile.txt_6T7sHv5E with you
Note that this is what happens to gmail. When I use the Outlook client on Windows connected to Exchange I don't get the attachment nor the second email. Yuk!
What a palaver! There's no way my business (Search and Rescue) will accept this API with the obvious obstacles for an email recipient! Can I reconstruct the full email as one without unintelligible binary attachments and without creating accounts on Microsoft?