Very new to Powershell. Wrote powershell script which is working perfectly but when it sends mail it does not show new line character in body. Following are configurations:
$EmailFrom = "[email protected]"
$EmailTo = "[email protected]"
$Subject = "Disk Space Low: $server"
$Body = "Server Name: $server, <NEED NEW LINE> Drive: C, <NEED NEW LINE> Total Size: $sizeGB, <NEED NEW LINE> Space Left: $freeSpaceGB"
$SMTPServer = "scan.opinergo.fn"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
#$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("<From mail ID>", "Password");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
In Body i have used following in place of ; searched around:
1) %0d%0a - NOT WORKING when user checks mail
2) \n - NOT WORKING when user checks mail
3) < br > - Not Working when user check mail
Could anyone please suggest what else could i use to get new line or any modifications required in script?
(From my comment)
The PowerShell newline indicator is `n (backtick-n), so:
$Body = "Server Name: $server, <NEED NEW LINE> Drive: C
becomes:
$Body = "Server Name: $server, `n Drive: C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With