Thursday, February 28, 2013

Send you the HTML file in email body through PowerShell

 This script will not send as a attachment, it will send you the HTML file in email body.


PowerShell
# Send email as a HTML body. 
$smtpServer = "SMTP Server Name" 
$MailFrom = "DL or Name of the person from where you need to send email" 
$mailto = "DL or Name of the person where you need to send email" 
$msg = new-object Net.Mail.MailMessage  
$smtp = new-object Net.Mail.SmtpClient($smtpServer)  
$msg.From = $MailFrom 
$msg.IsBodyHTML = $true 
$msg.To.Add($Mailto)  
$msg.Subject = "Report-Test." 
$MailTextT =  Get-Content  -Path C:\temp\Reports\Report.html 
$msg.Body = $MailTextT 
$smtp.Send($msg

1 comment:

  1. how to remove email notice from mail body or give break to notice? for exm. "FalseNotice: All email and instant messages (including attachments) sent to
    or from ***** personnel may be retained,
    monitored and/or reviewed by *** and its agents, or authorized
    law enforcement personnel, without further notice or consent.

    ReplyDelete