What do you someone breaks something? I post the solution here...

Kubernetes (K8s/K3d) / Terraform / Ansible / Linux / AWS / Docker / Bash / Python / ELK / CI/CD / Java / Traefik / Nginx / CentOs / Ubuntu




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 !!!!!😊
Powered by Blogger.