Saturday, 21 June 2014

PowerShell : How to sent mail using gmail SMTP

#---------------------------------------------------------------------------------------
$From = "Any.Singha@gmail.com"
$To = "Any.Singha@gmail.com"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
$Username = "Any.Singha@gmail.com"
$Password = "XXXX" # Give your password
$subject = "Welcome to Powershell Group Meet Bangalore"
$body = "Hi, All Welcome"

$smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);

$smtp.EnableSSL = $true
$smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
$smtp.Send($From, $To, $subject, $body);
#-----------------------------------------------------------------------------------

No comments:

Post a Comment

..Love

Born as Mathematician, Found love in Scripting and want to have an affair with C#

Total Pageviews