-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send-MgUserMail: Send a new message using MIME format #844
Comments
For those in the same position, use Delegated Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/me/sendMail" -Body $RequestBody -ContentType 'text/plain' Application level Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/users/$($UserId)/sendMail" -Body $RequestBody -ContentType 'text/plain' An example using Mailkit (DE0005) Add-Type -Path MailKit.dll
$Message = [MimeKit.MimeMessage]::new()
$Message.From.Add([MimeKit.InternetAddress]'sender@example.com')
$Message.To.Add([MimeKit.InternetAddress]'receiver@example.com')
$Message.Subject = 'Test'
$BodyBuilder = [MimeKit.BodyBuilder]::new()
$BodyBuilder.TextBody = 'This is a test message'
$Message.Body = $BodyBuilder.ToMessageBody()
$MessageStream = [System.IO.MemoryStream]::new()
$Message.WriteTo($MessageStream)
$MessageStream.Position = 0
$MessageStreamReader = [System.IO.StreamReader]::new($MessageStream, [System.Text.Encoding]::UTF8)
$MessageMIME = $MessageStreamReader.ReadToEnd()
$RequestBody = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($MessageMIME))
Invoke-MgGraphRequest -Method POST -Uri "https://graph.microsoft.com/v1.0/me/sendMail" -Body $RequestBody -ContentType 'text/plain' |
@peombwa is this something implemented in V2. |
@ddyett, MIME format is currently not supported by all SDKs due to missing MIME path in the metadata used to generate the SDKs. A workaround is to fall back to |
Transferred to microsoftgraph/msgraph-metadata#389. |
Support for sending a new message using MIME format with
Send-MgUserMail
https://docs.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http#example-4-send-a-new-message-using-mime-format
The text was updated successfully, but these errors were encountered: