HOW DO I SEND EMAIL USING POWERSHELL
#################################################################################
# Author: Shailesh Thakur
# Description: Send Email Using Powershell
# Version:1.0
#################################################################################
############################### Variables Declaration and Definition ################
$from=Read-Host -Prompt "Enter Your From Email"
$to=Read-Host -Prompt "Enter Email To Be Sent To"
$cc=Read-Host -Prompt "Enter Email to CC"
$subject=Read-Host -Prompt "Enter Subject of Your Email"
$body=Read-Host -Prompt "Type The Body of the Email"
$attachment=""
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $from -To $to -Subject $subject -Cc $cc -Body $body `
-SmtpServer $SMTPServer -Port $SMTPPort `
-UseSsl -Credential (Get-Credential)
#################################################################################
Note:One have to configure the from email to send email via program
the following link might be usefull
Comments are welcomed and i am ready to walk you through the code
HAPPY CODING !!!!!😊
2 comments:
good it works for me
thank you
Post a Comment