E-mail body being one line only

Home Forums Scripting PowerShell E-mail body being one line only

This topic contains 0 replies, has 1 voice, and was last updated by Avatar DreamweaverN 13 years ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    DreamweaverN
    Member
    #118195

    Hi again all.

    I’ve done this code:

    $message = New-Object System.Net.Mail.MailMessage($from, $to)
    $message.CC.Add($cc)
    $message.Subject = “System Information”
    $message.Body = $(Get-Content $body)
    $message.Attachments.Add($location)

    $smtpsend = New-Object System.Net.Mail.SMTPClient
    $smtpsend.Host = $mailserver
    $smtpsend.Send($message)[/CODE]

    Now, the attachment is fine but the body of the e-mail is coming out on just one line. It is just a normal text file. I assume it is to do with the line breaks but I haven’t tried changing it. This is in PowerShell. Any help would be fantastic because this is driving me nuts :grin:.[CODE]$message = New-Object System.Net.Mail.MailMessage($from, $to)
    $message.CC.Add($cc)
    $message.Subject = “System Information”
    $message.Body = $(Get-Content $body)
    $message.Attachments.Add($location)

    $smtpsend = New-Object System.Net.Mail.SMTPClient
    $smtpsend.Host = $mailserver
    $smtpsend.Send($message)[/CODE]

    Now, the attachment is fine but the body of the e-mail is coming out on just one line. It is just a normal text file. I assume it is to do with the line breaks but I haven’t tried changing it. This is in PowerShell. Any help would be fantastic because this is driving me nuts :grin:.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.