E-mail body being one line only

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

This topic contains 2 replies, has 2 voices, and was last updated by Avatar DreamweaverN 12 years, 12 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Avatar
    DreamweaverN
    Member
    #116995

    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:.

    Avatar
    ahinson
    Member
    #216147

    Re: E-mail body being one line only

    So the problem is that you can’t figure out how to wrap the text?

    Use html and insert your own formatting.

    Code:
    $message.IsBodyHtml = True
    Avatar
    DreamweaverN
    Member
    #286225

    Re: E-mail body being one line only

    I thought as much and tried it but the output still came out on one line. I had the output put in a

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.