1

I am sending a mail using the graph API from a shared mailbox ([email protected]).

There is a .CSV file added to this POST call. The mail is sent with the correct subject and body. However, the attachment is dropped.

The format looks perfect like it should be. Does anyone know why this is being dropped, and how to fix this?

This is my body sent to the endpoint

https://graph.microsoft.com/v1.0/users/[email protected]/sendMail 

Body:

{
  "saveToSentItems": "true",
  "message": {
    "attachments": [{
      "@odata.type": "#microsoft.graph.fileAttachment",
      "name": "data.csv",
      "contentBytes": "MYFILEINBASE64"
      "contentType": "text/csv"
    }],
    "message": {
      "toRecipients": [{"emailAddress": {"address": "[email protected]"}}],
      "subject": "Hello from runtime params",
      "body": {
        "contentType": "Text",
        "content": "This is a test mail body."
      }
    }
  }
}

Thanks !

2
  • How large is the file you are attempting to attach? Commented Oct 1 at 21:50
  • I'd also suggest trying the mime type text/plain. Commented Oct 1 at 21:55

1 Answer 1

1

The JSON you posted doesn't look valid you have the message property defined twice (eg you have a second message property after the attachment property)

It should be

{
  "saveToSentItems": "true",
  "message": {
    "attachments": [{
      "@odata.type": "#microsoft.graph.fileAttachment",
      "name": "data.csv",
      "contentBytes": "MYFILEINBASE64"
      "contentType":"text/csv"
    }],
      "toRecipients": [{"emailAddress": {"address": "[email protected]"}}],
      "subject": "Hello from runtime params",
      "body": {
        "contentType": "Text",
        "content": "This is a test mail body."
      
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This did the trick, the mail comes through without error, but it silently drops the attachment like this. Thanks !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.