Skip to content

[v2] Send-MgUserMail throws error even though it succeeds #1834

@jasonjoh

Description

@jasonjoh

The command results in the following error, but the email is sent.

Send-MgUserMail_Send: The server responded with an unrecognized response, Status: Accepted

A 202 Accepted is the expected response for the send mail API.

Version: 2.0.0-preview5

To reproduce:

Connect-MgGraph -Scopes "Mail.Send" -UseDeviceAuthentication

$context = Get-MgContext

$sendMailParams = @{
    Message = @{
        Subject = "Testing Microsoft Graph"
        Body = @{
            ContentType = "text"
            Content = "Hello world!"
        }
        ToRecipients = @(
            @{
                EmailAddress = @{
                    Address = $context.Account
                }
            }
        )
    }
}

Send-MgUserMail -UserId $context.Account -BodyParameter $sendMailParams

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions