Author Posts

December 4, 2014 at 8:27 am

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

December 4, 2014 at 8:36 am

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.

December 4, 2014 at 8:53 am

Interesting. OK. Thanks for the tip!