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-GmailMessage: Special characters not displayed as expected in HTML Body #361

Open
sjbruni opened this issue Nov 2, 2021 · 1 comment

Comments

@sjbruni
Copy link

sjbruni commented Nov 2, 2021

I'm trying to send a message using the function "send-gmailmessage" with attribute "-bodyashtml", and of course using HTML format in the body.
The issue is that when the message is received, the special characters like "ñ" and "ó" (the message is in Spanish), are not shown correctly.

For example show like "ñ" instead of "ñ" or "ó" instead of "ó"

I tried with the meta into the HTML:

But not working (of course tried also with "UTF-8" instead of "ISO-8859-1")

The powershell command line I'm using is:

Send-GmailMessage -From [email protected] -Subject "Test email sending" -Body $htmlContent -BodyAsHtml -To "[email protected]" -Attachments "[Path of the file to been attached]"

@francocatto
Copy link

francocatto commented Sep 15, 2023

I had the same issue. And I founded that the broken special characters in UTF-8 is generated by the missuse of the toString() for serializing the message with the C# class MimeKit.MimeMessage. Here the author of the lib explain why you shouldn't use this: jstedfast/MimeKit#554

MimeKit.MimeMessage is called from Send-GmailMessage on line:
$raw = New-MimeMessage @messageParams | Convert-Base64 -From NormalString -To WebSafeBase64String

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants