Skip to content
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 fails formatting html-encoded mails since 2.26.0 #3180

Closed
pbo-top opened this issue Feb 25, 2025 · 2 comments
Closed

Send-MgUserMail fails formatting html-encoded mails since 2.26.0 #3180

pbo-top opened this issue Feb 25, 2025 · 2 comments
Labels
status:duplicate A duplicate issue type:bug A broken experience

Comments

@pbo-top
Copy link

pbo-top commented Feb 25, 2025

Describe the bug

When calling Send-MgUserMail from Microsoft.Graph.Users.Actions 2.26.0 with content-type "html" the sent email contains unicode-like codes instead of the given html-tags. The code was running nicely with 2.25.0.
Characters such as: '
in the subject line also get garbled to some codes.

Mail sample:
Image

Expected behavior

Same code running but in 2.25.0, mail sample:

Image

How to reproduce

snippet of code:
`
$contenttype = "html"
$saveInSend = "true"

# Read the mail template from file
$mailTemplate = Get-Content "./body.html" -Raw


   $mailBody = $mailTemplate

    foreach ($property in $appRegSinner.PSObject.Properties) {
        $placeholder = "#{0}#" -f $property.Name
        $mailBody = $mailBody.Replace($placeholder, $property.Value)
    }
    
    $subject = "Registrering af Azure Application '$($appRegSinner.appName)' i ServiceNow"

    # Override the mail receiver address if specified
    $override = $overrideMailReceiverAddress.TrimEnd()
    if ($override -ne "none") {
        $appRegSinner.to = $overrideMailReceiverAddress
    }

    $params = @{
        Message = @{
            Subject = $subject
            Body    = @{
                ContentType = $contenttype
                Content     = $mailBody
            }
            ToRecipients = @(
                @{
                    EmailAddress = @{
                        Address = $appRegSinner.to
                    }
                }
            )
            CcRecipients = @(
                @{
                    EmailAddress = @{
                        Address = $appRegSinner.cc
                    }
                }
            )
        }
        SaveToSentItems = $saveInSend
    }
    
    Write-Information "Sending mail to $($appRegSinner.to)"
    $params | ConvertTo-Json -Depth 5 | Write-Information

    Send-MgUserMail -UserId $appRegSinner.from -BodyParameter $params

`

snippet of body.html
`
Du har oprettet denne Enterprise Application i Azure:

Navn: #appName#
AppID: #appId#

Den manglede at blive registreret i ServiceNow CMDB'en. Me... `

SDK Version

2.26.0

Latest version known to work for scenario above?

2.25.0

Known Workarounds

Force usage of 2.25.0 modules all around.

Debug output

Click to expand log ```
</details>


### Configuration

OS: Windows + Ubuntu
Powershell: 7.5.0

### Other information

_No response_
@pbo-top pbo-top added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Feb 25, 2025
@pbo-top
Copy link
Author

pbo-top commented Feb 25, 2025

The content of body.html failed to get rendered as code in the issue, but the file looks like this:

Image

@timayabi2020 timayabi2020 added status:duplicate A duplicate issue and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Feb 25, 2025
@timayabi2020
Copy link
Contributor

Hi @pbo-top apologies for the inconvenience. The issue had already been reported here #3160 and resolved. Please wait for the next release. I'll therefore close this as a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:duplicate A duplicate issue type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants