Sending Emails with Special Characters

by | January 23,2012

Table of Contents

Send Emails with PowerShell Using Send-MailMessage

PowerShell has built-in support for sending emails: Send-MailMessage! All you need is an SMTP server. However, with standard encoding you may run into issues where special characters are mangled.

-Encoding parameter and UTF8

Use the -Encoding parameter and specify UTF8 to preserve such characters. Here’s a sample with a German freemailer web.de:

Send-MailMessage -Body 'I can send special characters: äöüß' -From youraccountname@web.de -to someone@somewhere.com -Credential (Get-Credential youraccountname@web.de) -SmtpServer smtp.web.de -Subject 'Sending Mail From PowerShell' -Encoding ([System.Text.Encoding]::UTF8)

 
ReTweet this Tip!