Mariusz, Gorzoch tech Blog

How to send email with use of PowerShell

leave a comment »

I’m quite sick of looking for this info everytime I need it, so this time I decided to create post about it, so here it is. To send email with use of PowerShell you just need to issue those commands:

$emailFrom = "user@yourdomain.com"
$emailTo = "user@yourdomain.com"
$subject = "your subject"
$body = "your body"
$smtpServer = "your smtp server"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)

this is quite easy and usefull especialy if you need to check if the server where you are installing your app allow you to send emails (for some reasons this functionaliy is quite often blocked inside organizations).


Written by Mariusz Gorzoch

18 July 2009 at 08:46

Posted in Powershell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: