I want to add the encryption or the "do not forward" option to a mail message like in Outlook to mail messages using the send mail Graph API module. This is for a short term staging migration where we need to distribute sensitive information to particular recipients. I'm essentially looking for a way to implement one of the email encryption methods described here.
I've set up an application registration with application level API permissions to mail.send. I'm working in PowerShell using hashtables for the body/MIME parameters and converting to JSON. I'm also using Invoke-Restmethod to call the API. I've looked over all the supported parameters in the Messages MS Graph module, and they don't provide a solution there for adding this.
Essentially, I'm trying to add the end-to-end encryption solutions that are available in Outlook as parameters to the body (as I don't know that it's possible any other way). I've tried adding extended properties but cannot find the right attributes to key in on. Is there another API module that can add this functionality?
$message = @{
"message" = @{
"subject"= "Confidential Information: $($adUser.userprincipalname)"
"body" = @{
"contentType"= "html"
"content"= "
<p>Listed below is the confidential information.</p>
<table>
<tr>
<td>UserPrincipalName: </td>
<td>$($adUser.UserPrincipalName)</td>
</tr>
<tr>
<td>Confidential Information</td>
<td>$($Confidential)</td>
</tr>
</table>
"
}
"toRecipients"= @(
$formatRecipients
)
}
}
$jsonMessage = $message | ConvertTo-Json -Depth 10
$mailuri = "https://graph.microsoft.com/v1.0/users/automated.mail@company.com/sendMail"
# send mail with MS Graph send.mail permissions
$mailSend = Invoke-RestMethod -Uri $mailuri -Headers $headerParams -Method Post -Body $jsonMessage -ContentType application/json
This example is sending mail to the given recipients that are fed to the script, but it is only using the default mail protocols in Exchange for sending mail messages to users. I would like to set it so the messages cannot be forwarded or read if intercepted.