Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
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 video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now