Send-MailMessage Error

Hello,

I am running the following command to send an email:

send-mailmessage -from "Myself " -to "Someone ", -subject “My Subject” -body “Body Test Here” -Attachments “C:\myfile.txt” -priority High -dno onSuccess, onFailure -smtpServer smtpserver.mydomain.com

The above works and I receive the email with the attachment. However, after it runs, there is an error that states:

send-mailmessage : The specified string is not in the form required for an e-mail address.
At line:1 char:1

  • send-mailmessage -from 'Myself ’ -to 'Someone< …
  •   + CategoryInfo          : InvalidType: (:) [Send-MailMessage], FormatException
      + FullyQualifiedErrorId : FormatException,Microsoft.PowerShell.Commands.SendMailMessage
    
    

Any idea why I receive this error AND receive the email?

Thanks,

TB

It’s displaying an error being returned from your SMTP server, most likely. But, if it works, you can add -ErrorAction SilentlyContinue to suppress errors from the command.

Interesting. OK. Thanks for the tip!