-
-
Save disouzam/bd86783be8460bb78bddae3b96d10f92 to your computer and use it in GitHub Desktop.
This file contains 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
# Long command with many parameters all on one line | |
Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject "Test Email" -Body "This is a test email." -SmtpServer "smtp.example.com" -Port 587 -UseSsl -Credential (Get-Credential) -Attachments "C:\path\to\file.txt" -Priority High -DeliveryNotificationOption OnSuccess, OnFailure | |
# Equivalent command using splatting for readability | |
$mailParams = @{ | |
From = "[email protected]" | |
To = "[email protected]" | |
Subject = "Test Email" | |
Body = "This is a test email." | |
SmtpServer = "smtp.example.com" | |
Port = 587 | |
UseSsl = $true | |
Credential = (Get-Credential) | |
Attachments = "C:\path\to\file.txt" | |
Priority = "High" | |
DeliveryNotificationOption = "OnSuccess, OnFailure" | |
} | |
Send-MailMessage @mailParams |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment