Solved

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

Posted on 2013-06-19
3
494 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
  • 2
3 Comments
 
LVL 39

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 39

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 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