Send-MailMessage Error

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Douglas Tiffany Douglas Tiffany 2 years ago.

  • Author
    Posts
  • #20934
    Profile photo of Douglas Tiffany
    Douglas Tiffany
    Participant

    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

  • #20935
    Profile photo of Don Jones
    Don Jones
    Keymaster

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

  • #20938
    Profile photo of Douglas Tiffany
    Douglas Tiffany
    Participant

    Interesting. OK. Thanks for the tip!

You must be logged in to reply to this topic.