Powershell – Automated Email Report

Self explaining piece of code:

#———————————————————————————————————————————–
#Email options for automated emailed report
$smtpServer = “YOUR SMPT SERVER ADDRESS”
$txtFilePath = “c:\somefile.txt”
#
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($txtFilePath)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$msg.From = “Some Email Address”
$msg.To.Add(”Some Email Address”)
$msg.Subject = “Some Subject”
$msg.Body = “Some Body Data”
$msg.Attachments.Add($att)

$smtp.Send($msg)
#———————————————————————————————————————————–

Tags:

Locations of visitors to this page