Skip to content

Instantly share code, notes, and snippets.

@thomasrayner
Created May 9, 2017 13:45
Show Gist options
  • Save thomasrayner/cc45360044653f60dee5ed8180c4eb00 to your computer and use it in GitHub Desktop.
Save thomasrayner/cc45360044653f60dee5ed8180c4eb00 to your computer and use it in GitHub Desktop.
#Contents of MyFile.csv
#
#To,Subject,Body
#firstguy@fake.tld,subject1,<p>body</p>
#secondguy@fake.tld,subject2,<i>italic body</i>
$csvContents = Import-Csv MyFile.csv
$defaultEmailParams = @{
'SmtpServer' = 'EmailRelay'
'BodyAsHtml' = $true
'From' = '"Mr. Spammer" <spam@fake.tld>'
}
foreach ( $row in $csvContents ) {
$specificEmailParams = @{
'To' = $row.To
'Subject' = $row.Subject
'Body' = $row.Body
}
Send-MailMessage @defaultEmailParams @specificEmailParams
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment