Sending a mail through the internet is similar to the sending a letter. The major difference is that the mail delivered through the Internet is delivered instantly to the desired location. There are many methods of sending Emails. One can send the Email through the Standard Email client like google, yahoo etc. or you can use other email clients like MS Outlook etc.
Today I am going to discuss another method of sending the email using the Powershell. Powershell is one of the important scripting language which is used for task automation by the administrators. Using Powershell to send email with attachment is not a difficult job. Every system administrator should know the command to send email using Powershell.
Parameters of Send-MailMessage command: -
Send-MailMessage is the Command that is used in the Powershell to send email with attachment. Parameters that can be used with the Send –MailMessage are shown bellow.
Enter the Email address to which you want to send mail.
Enter the Email addresses that you would like to cc.
Enter the Email addresses that you would like to bcc.
Email address from where mail is to be send.
Enter the subject of the email message.
Type your message in the body section
Provide full path of the File to be attached.
This parameter indicates that the body contains the HYML Part.
An account that has permission to send the email. The default is the current user.
The parameter is used to know the delivery status of the email.
None – (Default) Indicates No notification.
OnSuccess – Indicates that the email has been delivered successfully.
OnFailure – Indicates that the email has not been delivered
Delay – It will notify if the delivery is delayed.
Never – It will not give any delivery notification.
Encoding technique that is used for the body and the Subject.
With thehelp you can Provide the priority to the email message. Valid values: Low, Normal (default), High
Enter name of the Server in it.
SSL stands for Secured Soket Layer. Use the SSL protocol to establish a connection to the SMTP server to send email.
Syntax of Powershell to send email with attachment: -
Send-MailMessage -To “Enter the recipient Email Address” -To”Enter more email address if you require” –cc ”Enter Email address that you would like to CC” – bcc ”Enter Email Address that you like to Bcc” –From “Enter the Sender’s Email address” –Subject “Enter the Subject” –Body “ Type your message” –Attachment $Enter the path of the file –SmtpServer abc.domainname.com
The method of using Powershell to send email with attachment explained in the post will help you a lot. If you are unable to send Mail using the Powershell please comment with the error that you are getting we will sort out your query as soon as possible.