PowerShell’de Mail Gönderme

Şimdi Windows PowerShell kullanarak basit biremail gönderme scripti yazalım.

$smtpServer = "smtp.gmail.com"
$smtpUser = "emailaddress@gmail.com"
$smtpPass = "password"
$mail = New-Object System.Net.Mail.MailMessage
$mail.From = New-Object System.Net.Mail.MailAddress($smtpUser)
$mail.To.Add("sendtoemail@hotmail.com")
$mail.Subject = "Hi"
$mail.Body = "Hello World!"
$smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer
$smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPass
$smtp.Send($mail)
Share
Leave a comment

2 Comments.

Leave a Reply


[ Ctrl + Enter ]

*