1
votes

I am using Microsoft graph SDK for sending mail using office 365 account from my iOS application recently I am able to send mail body but I am not able to send attachments with it, I am referring This link for the attachment but could not able to send attachments.

I have tried to hit https://graph.microsoft.com/v1.0/me/sendMail URL using following JSON

{ "message":{ "subject":"Meet for lunch?", "hasAttachments":true, "body":{ "contentType":"Text", "content":"The new cafeteria is open." }, "toRecipients":[ { "emailAddress":{ "address":"[email protected]" } } ], "attachments":[ { "@odata.type":"#Microsoft.OutlookServices.FileAttachment", "name":"menu.png", "Content-Type":"multipart/mixed" "contentBytes":"base64 string" } ] }, "saveToSentItems":"false" }

with header of

"content-type":"application/x-www-form-urlencoded"

"Authorization" : "bearer"

but I am getting status code 415 with unsupported media type.

2

2 Answers

1
votes

Ratzz,

The Content-Type property is for the attachment itself, not for the top level of the MIME message. So the value should be "image/png" rather than "multipart.mixed". Similarly, you would use "application/pdf" for an attached PDF doc or image.

Please give it a try.

regards, Dana Birkby

-1
votes

this is an old question, but i just hit this issue and if you remove "Content-Type":"multipart/mixed" you should be fine or add a comma after it ;)