How to send email with attachments using PowerShell

You can send emails from using Power-Shell. You can include attachments as well.

Warning: If your smtp provider allows anonymous authentication you can send email ending domain.

eg: send email from

$SmtpClient = New-Object
$ = ""
$MailMessage = New-Object
$MailMessage.from = ""
$MailMessage.IsBodyHtml = 0
$MailMessage.Subject = "Test"
$MailMessage.Body = "Testing testing email testing :)"
$file = "c:\testfile.xls"
$att = new-object Net.Mail.Attachment($file)

Leave a Reply

Your email address will not be published. Required fields are marked *