Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 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