Skip to content

Instantly share code, notes, and snippets.

@razer86
Created September 5, 2024 03:56
Show Gist options
  • Save razer86/8c046459abed9a9ceb1d95d4df3e2c56 to your computer and use it in GitHub Desktop.
Save razer86/8c046459abed9a9ceb1d95d4df3e2c56 to your computer and use it in GitHub Desktop.
$authemail = "[email protected]"
$authpassword = "UserPassword1!"
$smtpserver = "smtp.office365.com"
$smtpport = "587"
$fromemail = "[email protected]"
$toemail = "[email protected]"
$timestamp = Get-Date -Format "dddd MM/dd/yyyy HH:mm K"
[System.Net.ServicePointManager]::SecurityProtocol = 'Tls,TLS11,TLS12'
$secpasswd = ConvertTo-SecureString $authpassword -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($authemail, $secpasswd)
$sendMailMessageSplat = @{
SmtpServer = $smtpserver
Port = $smtpport
UseSsl = $true
Credential = $cred
From = $fromemail
To = $toemail
Subject = "Powershell Email Test"
Body = $timestamp
}
Send-MailMessage @sendMailMessageSplat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment