graph api problem sendmail with attachement (Frank Lehmann) 0 Reputation points

Following scenario: I have a mail with attachements (pdf, csv) files. I read the messages attachments with graph api /attachements and messageid ! I copied the contenByte value to clipboard and start a new post request with sendmail with attachment. I copied my clipboard to this new post request and want to see, if i can send a mail with attachment. The mail is sent, but the pdf attachment is broken after that. The csv attachment is working fine. What is wrong here ?

                      "message": {
                        "subject": "Hallo Welt",
                        "body": {
                          "contentType": "html",
                          "content": "Noch mehr Welt<br>Mit freundlichem Gruß<br><br><br>Frank Lehmann<br>Lindenstrasse 10a<br>28755 Bremen<br><br>Tel:0421-56507289<br>Mail:<br><br><br><a href=&ldquo;;>Für jede Bewertung pflanzen wir einen Baum !</a>"
                    },"toRecipients": [{"emailAddress": {"address": ""}} ],"attachments": [{
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "180628_Bericht_Digitalisierungsumfrage.pdf",
        "contentType": "application/pdf",
        "contentBytes": "OztNO0w7OzsNCjEwMTtEZWNrbGVpc3QgUmFt...(more)"
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "Kopie von Preisliste_2023_2024.csv",
        "contentType": "application/",
        "contentBytes": "OztNO0w7OzsNCjEwMTtEZWNrbG..(more)"
      } ]},"saveToSentItems": "true"
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,839 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Siddharth Gautam 855 Reputation points

    Hello (Frank Lehmann),

    Thanks for posting!

    As per my Investigation, it seems there is some issue with the value of pdf attachment content Byte which you are using to send mail with attachment i.e., content Byte value you are passing is incorrect. I am able to replicate the same scenario i.e., broken pdf when I am passing incorrect content Byte value.

    I would suggest you compare both (working and non-working content byte values) the content byte values.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments