Solved

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

Posted on 2013-06-19
3
497 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

A brief introduction to what I consider to be the best editor for PowerShell.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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