Powershell here-strings

Does Syncro scripting respect here-strings? I am trying to send a simply formatted email, but the body just gets run together. For example,

$mail_body = @"
this is the first line.

this is the third.
"@

gets sent as

“this is the first line. this is the third.”

I tried adding

$PSDefaultParameterValues['*:Encoding'] = 'utf8'

but it made no difference.

I haven’t tested it in this context, but using rn to represent line feeds should work…

$mail_body = @"`r`n
this is the first line.`r`n
`r`n
this is the third.`r`n
"@

Note: Those aren’t apostrophes, but rather the backwards ones.

I have tested that approach - same result.

Hmm…

It might not be ideal, but I just tested this, and it worked:

$mail_body = @"
Line 1<br>
Line 2<br>
Line 3
"@

Ha, I would not have thought of that. But yes, it is working in my script.

Thank you!

1 Like