Is Microsoft Graph API v1.0 reference can we Send Encrypted PDF in attachment?

Akila R 21 Reputation points
2022-09-02T13:12:26.323+00:00

I am new to MS graph API. I am trying to send encrypted attachment using Microsoft Graph API v1.0 reference .Plain PDF file attachment is working fine. I don't have idea about send Encrypted PDF using sendmail Api. Guide me how to achieve this

Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-09-06T06:15:17.237+00:00

    Hi @Akila R ,

    We can send PDFs Encrypt with Password, following example snippet shows how I am able to use /me/sendMail send a PDF file that is password protected.

    In message body attachments property contentBytes we should pass Base64Encoded string.

    POST https://graph.microsoft.com/v1.0/me/sendMail  
    Content-type: application/json  
    
    {  
      "message": {  
        "subject": "Send Mail with encrypted PDF",  
        "body": {  
          "contentType": "Text",  
          "content": "Attached PDF is a password protected."  
        },  
        "toRecipients": [  
          {  
            "emailAddress": {  
              "address": "{emailAddress}"  
            }  
          }  
        ],  
        "attachments": [  
          {  
            "@odata.type": "#microsoft.graph.fileAttachment",  
            "name": "secured.pdf",  
            "contentType": "application/pdf",  
            "contentBytes": "{Base64EncodedString}"  
          }  
        ]  
      }  
    }  
    

    Here is the results of my test, in the below screenshots secured.pdf is a password protected file.
    For this test I used a online free Base64Encoding tool to upload the file and that generates the Base64Encoded string.
    238010-post-sendmail.png
    238041-sentmail-with-pdf.png

    Please note sendmail on the fly with file Attachment, can support upto 3MB of file. As content is sent in the Base64Encoded string. For sending larger files with size more than 3MB consider using outlook-large-attachments.

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.