Send-MailMessage Error

Welcome Forums General PowerShell Q&A Send-MailMessage Error

This topic contains 2 replies, has 2 voices, and was last updated by

4 years, 1 month ago.

  • Author
  • #20934

    Points: 0
    Rank: Member


    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

    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

    Points: 1,785
    Helping HandTeam Member
    Rank: Community Hero

    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.

  • #20938

    Points: 0
    Rank: Member

    Interesting. OK. Thanks for the tip!

The topic ‘Send-MailMessage Error’ is closed to new replies.