Created
September 5, 2024 03:56
-
-
Save razer86/8c046459abed9a9ceb1d95d4df3e2c56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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