Prerequisites:-
SMTP relay server domain name of IP address
SMTP relay server port reach-ability
SMTP relay server credentials
Save content specified below in sendemail.ps1 file
SMTP relay server domain name of IP address
SMTP relay server port reach-ability
SMTP relay server credentials
Save content specified below in sendemail.ps1 file
############################################################################## $From = "YourEmail@gmail.com" $To = "AnotherEmail@YourDomain.com" $Cc = "YourBoss@YourDomain.com" $Attachment = "C:\temp\Some random file.txt" $Subject = "Email Subject" $Body = "Insert body text here" $SMTPServer = "smtp.xyz.com" $SMTPPort = "587" Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject ` -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl ` -Credential (Get-Credential) -Attachments $Attachment ##############################################################################
Execute the power shell script as below,./sendemail.ps1Regards,Sandeep Panchal.
No comments:
Post a Comment