Send Mail with PowerShell

Send Mail with PowerShell

We can create a basic function to send email with PowerShell by using the following, we will call it Send-SimpleMail. function Send-SimpleMail ([st

Reading and Writing to SQL Databases with PowerShell
IIS with ASP.NET support check
Mapped Drive with Encrypted Password

We can create a basic function to send email with PowerShell by using the following, we will call it Send-SimpleMail.

function Send-SimpleMail ([string]$subject, [string]$body)
{
$From = "youremail@yourcompany.com"
$To = "recipientemail@yourcompany.com"
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($stmpserver, 587)
$SMTPClient.EnableSSL = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("username" "Password");
$SMTPClient.Send($from, $to, $subject, $Body)
}
Send-SimpleMail -subejct "Test-Subject" -body "Testing body text."

COMMENTS

WORDPRESS: 0