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

    Exchange 2007/2010 – Custom System message – HTML format

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

Leave a reply to lz Cancel reply