send mailmessage powershell code example
Example 1: how to send mail and attachment using powershell
$file = "C:\folder\file.csv"
$att = new-object Net.Mail.Attachment($file)
Example 2: powershell send-mailmessage authentication
Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject "Something interesting just happened" -Body "Here's the details about the interesting thing" -SmtpServer smtp.myisp.net -Port 587 -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "[email protected]",(Get-Content -Path [email protected] | ConvertTo-SecureString))