-->

Powershell - Ship E-Mail Through Gmail Smtp Server

Powershell - Ship E-Mail Through Gmail Smtp Server

I came across an representative where I had to ship an electronic mail through Powershell.  This is the powershell script that I came upward amongst too tested.

constituent sendMyEmail ($fromAddress, $toAddress, $subject, $body, $password)
{
    # The sendEmail constituent is setup to purpose a GMail STMP Server amongst a valid draw of piece of job organisation human relationship    
    $SMTPServer = "smtp.gmail.com"
    $SMTPClient = New-Object System.Net.Mail.SmtpClient
    $SMTPClient.Host = 'smtp.gmail.com'
    $SMTPClient.Port = 587
    $SMTPClient.EnableSsl = $true
    $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($fromAddress, $password);
    $SMTPClient.Send($fromAddress, $toAddress, $subject, $body)
}
constituent gatherInfo {
}
#Main 
$smtpInfo = New-Object PSObject -Property @{
    fromAddress = $null
    toAddress = $null
    discipline = $null
    trunk = $null
    password = $null
}
$smtpInfo.fromAddress = "myemail@gmail.com"
$smtpInfo.toAddress = "mystuff@scriptkitty.work"
$smtpInfo.subject = "Awesome Email"
$smtpInfo.body = "Email is Awesome"
$smtpInfo.password = "xxxxxxxxxxxxx"
gatherInfo
sendMyEmail -fromAddress $smtpInfo.fromAddress -toAddress $smtpInfo.toAddress -subject $smtpInfo.subject -body $smtpInfo.body -password $smtpInfo.password
Blogger
Disqus
Pilih Sistem Komentar

No comments

Advertiser