We help IT Professionals succeed at work.
Get Started

Modfiy scriopt to embed txt into body of email

98 Views
Last Modified: 2018-11-16
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]
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2019
Most Valuable Expert 2018
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE