Modfiy scriopt to embed txt into body of email

I would like to modify the following script so that it will embed the contents of the source file in the body of the email:

The source file is at:

C:\Users\User\Desktop\File\file.txt


[code][/###PROGRAM START###
      # Invokes the Send-MailMessage function to send notification email
      $splat = @{
            From =                  'email1@email.com'
            To =                  Get-Content -Path ( Join-Path $PSScriptRoot 'DistList..txt')
            SmtpServer =      'smtp.smtp.com'
            Subject =            $subject
            body =                  $MessageBody
            BodyAsHtml =      $true
      }
      Send-MailMessage @splat
###PROGRAM END###code]
100questionsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Since you want to send this as html, you need to tell more, especially if you want to add to $MessageBody, and if so, what are its contents?
100questionsAuthor Commented:
The message body is only test which resembles something like this:

ORDERS:

Number: 12345

Item 1: ABC: 789456153212, Desc: adkl;fjakl;djfklajkl;j;afss, Qty: 500, Price: $1.00
Item 2: ABC: 456456545466, Desc: jakldfjakl;jdfl;kajflkjdl;s, Qty: 400, Price: $2.00
Item 3: ABC: 125212313123, Desc: akljdfkl;ajdflkjakl;djsf;d, Qty: 300, Price: $3.00
Item 4: ABC: 456465456466, Desc: aabblblbllllalalllalalllllla, Qty: 200, Price: $4.00
Item 5: UPC: 123456545564, Desc: uiuadsfjal;fdjal;kjdfl;akj, Qty: 100, Price: $5.00
Total: $0000.00
oBdACommented:
Since there's nothing requiring html in there, do you really need BodyAsHtml?
###PROGRAM START###
# Invokes the Send-MailMessage function to send notification email
$splat = @{
	From =			'email1@email.com'
	To =			Get-Content -Path (Join-Path $PSScriptRoot 'DistList..txt')
	SmtpServer =	'smtp.smtp.com'
	Subject =		$subject
	body =			$MessageBody + "`r`n" + ([IO.File]::ReadAllText('C:\Users\User\Desktop\File\file.txt'))
	BodyAsHtml =	$false
}
Send-MailMessage @splat
###PROGRAM END###

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

100questionsAuthor Commented:
Thanks oBda, I realliy don't need BodyAsHtml..  let me try the script, many thanks,
100questionsAuthor Commented:
oBdA, thanks again, just ran the script, however it does not respect the different lines shown in the data I provided..
In the body, it should reflect a new line, when the new line appears in the raw data.
Any changes?
100questionsAuthor Commented:
It seems like Outlook was removing extra line breaks...…
Not sure how to force this in the script...…
Perhaps it's not possible..
100questionsAuthor Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.