I am working on a PowerShell script that needs to forward emails that I get with the Graph API. I already have the Azure App Registration and necessary consents figured out and can get the emails via Get-MGuserMessage. The issue is when I call Invoke-MgForwardUserMessage that the script hangs for about 30 seconds then fails with: tooManyRetries ErrorCode. I am calling the function with the below code. Most of what is written below is some form of what the Microsoft docs say to write... Any ideas?
$userId is my ObjectID in Azure. $mail.Id is the GraphAPI gotten message "Id" field.
$params = @{
Message = @{
IsDeliveryReceiptRequested = $true
ToRecipients = @(
@{
EmailAddress = @{
Name = "Not Real Person"
Address = "notreal@notreal.org"
}
}
)
}
Comment = "Just want to make sure you get this."
}
Invoke-MgForwardUserMessage -UserId $userId -MessageId $mail.Id -BodyParameter $params