Powershell send-mail message adding extra characters to subject line

Powershell send-mail message adding extra characters to subject line

I am using a very simple script to send an email to Support Center to automate the creation of a request for a report.

  1. $MessageContent = "
  2. Assign To John Doe

  3. Test Test Test

  4. "
  5. $Subjectline = 'Test Subject '


  6. Send-MailMessage -To "Support Center <support.center@manageengine.com>" `
  7. -From "John Doe <john.doe@email.com>" `
  8. -SmtpServer smtpserver@email.com `
  9. -Subject $Subjectline `
  10. -Body $MessageContent

I have specified the $MessageContent to include CR's without using -BodyAsHTML since plain text will work fine. When I specify the -Subject either as a variable(like I have shown in the script) or a string quoted inline, I get a request created with extra text in the Subject line.

E.g. I run the script above and I get a new request in Support Center with the Subject of "=?us-ascii?Q?Test Subject?=". This does not happen when I send the email to any other destination.

                New to ADSelfService Plus?