Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

new Line not working

$
0
0

$session = New-PSSession -ConfigurationName microsoft.exchange -ConnectionUri http://ph-cdo-caexch01.gbsorg.net/powershell -Authentication kerberos
Import-PSSession $session

$isTherePossibleQueue = $false
$emailBody = "";

foreach ($databaseQueueEntry in get-queue) {
    if ($databaseQueueEntry.MessageCount -ge 1) {
        $isTherePossibleQueue = $true

        $emailBody += "Queue ID: " + $databaseQueueEntry.Identity + " Count:" + $databaseQueueEntry.MessageCount + "`n"
    }
}

if ($isTherePossibleQueue) {
    $smtpServer = "cdo-zimbra01.gbsorg.net"
    $msgSender = New-Object Net.Mail.SmtpClient($smtpServer)
    $msgComposition = New-Object Net.Mail.MailMessage

    $msgComposition.From = "exchange-hubcas@concentrix.com"
    $msgComposition.ReplyTo = "windows_administrators@concentrix.com"

    $msgComposition.To.Add("sheen.lim@concentrix.com")
    $msgComposition.Subject = "Possible High Mail Queue"
    $msgComposition.Body = $emailBody

    $msgSender.Send($msgComposition)
}

I'm having problem with my code in line

$emailBody += "Queue ID: " + $databaseQueueEntry.Identity + " Count:" + $databaseQueueEntry.MessageCount + "`n"

because what i receive in email is a straight line. that is suppose to be a new line per database queue entry.

Isnt `n the newline character in powershell?


Viewing all articles
Browse latest Browse all 21975

Trending Articles