by admin » Fri May 13, 2016 11:25 pm
Answer:
You can use the send-mailmessage cmdlet.
The following is a sample code snippet on how to use the send-mailmessage cmdlet. You can type in get-help send-mailmessage to get the full syntax of the cmdlet.
$emailToAddress="User One<userone@email.com.au>","User Two <usertwo@email.com.au>"
$mymailSubject="Error !!!!!"
$senderAddress= "Some Server<donotreply@email.com.au>"
$message="Please see attached error log."
$mysmtpServer="smtp.email.com.au"
$attachment="c:\myprogram\errorlog.txt"
send-mailmessage -To $emailToAddress -Subject $mymailSubject -From $senderAddress -Body $message -SmtpServer $mysmtpServer -Attachment $attachment