Send-MailMessage – Exchange 2007 sp2 and Exchange 2010

Sending email throught command had multiple steps,  now Exchagne 2007 SP2 which works on Powershell V2 has introduced a new cmdlet Send-Mailmessage. Sending email with Send-MailEssage is just single line command Below is the example of the same

Send-MailMessage –From Krishna.k@domain.com –To Rajesh@domain.com –Subject “Send-MailMessage Test” –Body “Send-MailMessage Test”  -Attachments “c:\Attachment.txt” –SmtpServer Hubserver.domain

5 thoughts on “Send-MailMessage – Exchange 2007 sp2 and Exchange 2010

  1. Hi Krishna:

    Good command but I am having an error from powershell in exchange 2010. Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.3.2 Service not available

    Any ideas
    lee

  2. Hi,

    Thanks, its a cool option i was looking for.

    How can we add multiple lines to the body (i.e. one sentence in the first line and second sentence in second line)

  3. Hi Chandran,

    You shold be able to use multiple lines. Below is the example of how you can use html with multiline

    $BodyMessage = @”
    This is the test body of the message with multiline.. wanted to test on this This data will be printed on the next line “@

    Send-MailMessage –From Krishna.k@domain.com –To Rajesh@domain.com –Subject “Send-MailMessage Test” –Body $BodyMessage -Attachments “c:\Attachment.txt” –SmtpServer Hubserver.domain

    Below link has some details on html sytax

    https://smtpport25.wordpress.com/2010/05/28/exchange-20072010-custom-system-message-html-format/

    Please Let me know if you need any more information..
    Regards,
    Krishna

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s