SCRIPT - 1
************************************* being script ***************
#OFFICE 365 working
$email_username="username@xyz.com"
$email_password = ConvertTo-SecureString -string "password" -AsPlainText -Force;
$email_smtp_host = "smtp.office365.com";
$email_smtp_port = 25;
$email_smtp_SSL = 1;
$email_from_address = "username@xyz.com";
$email_to_addressArray = @("himanshu@test.in");
$credential=New-Object System.Management.Automation.PSCredential($email_username,$email_password);
cls
Send-MailMessage -From "$email_from_address" -To $email_to_addressArray -Subject "Test email from powershell" -Body "This is only a test" -SmtpServer $email_smtp_host -Credential $credential -UseSsl -Port $email_smtp_port
********************************** END ************************
SCRIPT - 2 for HVE accounts - Test high volume email by using Send-MailMessage PowerShell cmdlet | Microsoft Learn
************************************* being script ***************
param (
[Parameter(Mandatory = $true)]
[string]$senderEmailAddress,
[Parameter(Mandatory = $true)]
[string]$recipientEmailAddresses,
[Parameter(Mandatory = $true)]
[string]$subject,
[Parameter(Mandatory = $true)]
[string]$body
)
$smtpServer = "smtp-hve.office365.com"
$smtpPort = "587"
# Prompt user for sender credentials
$credentials = Get-Credential -UserName $senderEmailAddress -Message "Enter sender credentials"
# Test HVE account
Send-MailMessage -From $senderEmailAddress -To $recipientEmailAddresses -Subject $subject -Body $body -SmtpServer $smtpServer -Port $smtpPort -UseSsl -Credential $credentials
********************************** END ************************
No comments:
Post a Comment