E=mc2
asked on
Change script to look at text file for destination email addresses
I would like to change this script, so that instead of hard coding in the destination email addresses, it will look into a flat txt file and use the email addresses listed in that specific file instead.
###SETUP START###
#-------DO NOT MODIFY-------#
#Yesterdays Date
$date = ((Get-Date).AddDays(-2)).T oString("M MM/dd/yyyy ")
###SETUP END###
###USER VARIABLES START###
#-------MODIFY AS NEEDED-------#
#Mail Subject
$Subject = "Report: "+$date+" REVISED "
#Body of Email
$MessageBody = "REVISED - Report for $date. Thank you."
###USER VARIABLES END###
###PROGRAM START###
# Invokes the Send-MailMessage function to send notification email
Send-MailMessage -From 'email1@mail.com' -To 'email2@mail.com', 'email3@mail.com', 'email4@mail.com' `
-SmtpServer 'smtp.mail.com' `
-Subject $subject `
-body $MessageBody `
-BodyAsHtml `
-Attachment 'C:\Attachment\Attachment. pdf'
###PROGRAM END###
Thanks in advance for your assistance
###SETUP START###
#-------DO NOT MODIFY-------#
#Yesterdays Date
$date = ((Get-Date).AddDays(-2)).T
###SETUP END###
###USER VARIABLES START###
#-------MODIFY AS NEEDED-------#
#Mail Subject
$Subject = "Report: "+$date+" REVISED "
#Body of Email
$MessageBody = "REVISED - Report for $date. Thank you."
###USER VARIABLES END###
###PROGRAM START###
# Invokes the Send-MailMessage function to send notification email
Send-MailMessage -From 'email1@mail.com' -To 'email2@mail.com', 'email3@mail.com', 'email4@mail.com' `
-SmtpServer 'smtp.mail.com' `
-Subject $subject `
-body $MessageBody `
-BodyAsHtml `
-Attachment 'C:\Attachment\Attachment.
###PROGRAM END###
Thanks in advance for your assistance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The usual: one address per line.
ASKER
Thanks very much, this is exactly what I was looking for, spot on.
ASKER