How to send an email with attachment using PowerShell

Configurare noua (How To)


This example sends an email message with an attachment.


Run the PowerShell command:

Send-MailMessage -From ‘User01 <>’ -To ‘User02 <>’, ‘User03 <>’ -Subject ‘Sending the Attachment’ -Body “Forgot to send the attachment. Sending now.” -Attachments .\data.csv -Priority High -DeliveryNotificationOption OnSuccess, OnFailure -SmtpServer ‘’

The Send-MailMessage cmdlet uses the From parameter to specify the message’s sender. The To parameter specifies the message’s recipients. The Subject parameter describes the content of the message. The Body parameter is the content of the message.

The Attachments parameter specifies the file in the current directory that is attached to the email message. The Priority parameter sets the message to High priority. The -DeliveryNotificationOption parameter specifies two values, OnSuccess and OnFailure. The sender will receive email notifications to confirm the success or failure of the message delivery. The SmtpServer parameter sets the SMTP server to

Tip solutie



(4 din 6 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?