0

My subject is probably not worded correctly.

I am working on some scripts and using the "Send-MailMessage" command. I need to have some variables in the body of the message.... How can I do this? These variables are directories, log file locations, IP addresses, etc from the script. When the script finishes or fails I need to send an email with pertinent info about the job..

$bod = "this is message please see log file at $logfilelocation"

Send-MailMessage -To [email protected] -Subject subject -From [email protected] -body $bod -SmtpServer server

1 Answer 1

2

You've already got the right idea. You just need to build up your $bod string using the variables. A 'here' string would probably work well. Something like:

$bod=@"
directory: $directory
log file location: $logfileLocation
ip address: $ipAddress
"@

Or are you asking how to get those values into variables?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.