Why does Send-MailMessage turn German umlauts into question marks?

November 14, 2026 4 answers
Asked by q17+maildrop_603

I'm sending company emails from a PowerShell script that reads a CSV. German characters in the message body arrive as question marks. I've tried different encoding values and also tried HTML, but the HTML attempt produced an error.

For now I need to use Send-MailMessage, even though it's obsolete. The umlauts are hardcoded in the body rather than coming from the CSV. What should I check, and can an HTML body contain variables?

Answers

u_72~parcel

Check the text before it ever reaches Send-MailMessage. Print the body variable in the same session that runs the script. If it already contains question marks, changing the mail encoding won't recover the original characters.

Script file encoding is worth checking here. In Windows PowerShell 5.1, a UTF-8 script without a byte order mark can be read incorrectly. Try saving the script as UTF-8 with BOM, then run it again. If the body looks correct before sending, specify -Encoding UTF8 on Send-MailMessage and check the received message.

++nearly!sorted:

An editor's Save with Encoding option is usually where you can choose UTF-8 with BOM. The exact wording depends on the editor.

Reply to this answer
x317~doorstop_4

Yes, an HTML body can contain variables. Build the body as a double-quoted PowerShell string, then pass it as the Body value and use BodyAsHtml. For a property expression inside the string, use syntax like $($line.Server).

BodyAsHtml is a switch, not the body text itself. If it still errors, the exact error and the Send-MailMessage call would help narrow down what's wrong. HTML alone doesn't fix the encoding, so check the body text before sending it too.

Reply to this answer
Kavren-4m

Take a close look at the actual send command. If you're building a hashtable named $sendMailMessageSplat, the call needs to use it, for example Send-MailMessage @sendMailMessageSplat. Include Encoding = 'UTF8' in that hashtable if you want to set it there.

A bare Send-MailMessage call doesn't automatically pick up a hashtable just because it's defined above it. If the posted command was simplified, compare it with the real one before changing anything.

Reply to this answer
f621~ratchet_3

Since the affected characters are hardcoded, I'd leave the CSV alone while testing the message body. If you later send text from the CSV, check the encoding at every read and write as well as at the send step. Rewriting the file with Get-Content and Set-Content can change its encoding depending on the PowerShell version and parameters used.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions