Solved

How to add color to the text body of an email sent with powershell ?

Posted on 2013-06-19
3
498 Views
Last Modified: 2013-06-19
If I have the following:

$msg.Body = "VMware HealthCheck vCenter2"

How do i make that text looked red in the body message when i receive the email ?

Thanks,
0
Comment
Question by:namerg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 40

Expert Comment

by:footech
ID: 39260529
Your body would need HTML formatting.  Something like
$msg.Body = "<font color=red>VMware HealthCheck vCenter2</font>"

Open in new window

You have to make sure you're sending the email as HTML as well.
0
 

Author Comment

by:namerg
ID: 39260551
Hmm, I have the following where would I enable it for HTML ?

$enablemail="yes"
$emailattachment = "C:\scripts\VMware\HealthCheckvCenter2.xlsx"
$smtpServer = "ux3t" 
$mailfrom = "VMware Healtcheck <VMWareTech>"
$mailto = "Me"

if ($enablemail -match "yes") 
{ 
	$msg = new-object Net.Mail.MailMessage
	$att1 = new-object Net.Mail.Attachment($emailattachment)
	$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
	$msg.From = $mailfrom
	$msg.To.Add($mailto) 
	$msg.Subject = "VMware Health vCenter2"
	$msg.Body = "VMware HealthCheck vCenter2"
	$msg.Attachments.Add($att1)
	$smtp.Send($msg)
	$att1.Dispose()

Open in new window

0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39260610
Add the following anywhere after $msg is defined and before it is sent.
$msg.IsBodyHTML = $true

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question