Professional Documents
Culture Documents
Windows PowerShell Script - Send E-Mail With Attachment
Windows PowerShell Script - Send E-Mail With Attachment
$filename = c:\temp\profile.ps1 $smtpServer = server-name or IP $msg = new-object Net.Mail.MailMessage $att = new-object Net.Mail.Attachment($filename) $smtp = new-object Net.Mail.SmtpClient($smtpServer) $msg.From = who@from.com $msg.To.Add(who@to.com) $msg.Subject = Email Subject $msg.Body = Body of email goes here. $msg.Attachments.Add($att) $smtp.Send($msg)