This script used to work, but no longer does. I have tried a number of different examples, but nothing happens. I have 3 different emails to choose from, yahoo, gmail, and hostgator. None of them work.
$From = "me@me.com"
$To = "me@gmail.com"
$Attachment = "C:\Users\Public\Documents\EmailOrderList\OrderList.txt"
$Subject = "Subject"
$Body = "Order List Attached"
#$Body = $args[0]
$SMTPServer = "mymailserver.com"
$username = "MyUserName"
$password = "Password" | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
$SMTPPort = "587"
#$SMTPPort = "465" This one does not work
#Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject `
#-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
#-Credential (Get-Credential)
Send-MailMessage -ErrorAction Stop -from "$From" -to "$To" -subject "$Subject" -body "$Body" -attachment "$Attachment" -SmtpServer "$SMTPserver" -Priority "Normal" -Credential $credential -Port $SMTPPort -UseSsl