Use Below scripts convert in HTML format and send to mail in singal command :-
top -b -n 1 | /tmp/healthcheckreport.sh | mail -s "Server load" -a "Content-Type: text/html" mail@gmail.com
The default formatting results in messages that look something like this.
The HTML for that email message was created by piping the output from one command into the ConvertTo-HTML cmdlet. Fortunately ConvertTo-HTML has the -Head parameter that can be used to add style information to the HTML that it generates.
For example, by adding this line to the script used in the last article we can change the font to something a little nicer to look at.
Note: extra spaces have been added to the style tags so that WordPress does not remove them.
Then modify the ConvertTo-HTML cmdlet to add the -Head parameter.
This time when the script is run the email looks like this instead.
That is a little better, but we can do a lot more. How about we add some more styles to the table and really make it look nice.
Again note that extra spaces were added to the style tags above to preserve them in WordPress.
Now the script produces an email that looks like this.
Although this requires you to know a little bit about how HTML styles work, it is a pretty easy topic to learn and once you get a few working styles in your scripting tool kit you can just use them over and over again.
top -b -n 1 | /tmp/healthcheckreport.sh | mail -s "Server load" -a "Content-Type: text/html" mail@gmail.com
The default formatting results in messages that look something like this.
The HTML for that email message was created by piping the output from one command into the ConvertTo-HTML cmdlet. Fortunately ConvertTo-HTML has the -Head parameter that can be used to add style information to the HTML that it generates.
For example, by adding this line to the script used in the last article we can change the font to something a little nicer to look at.
$style = "< style>BODY{font:arial 10pt;}< /style>"
Note: extra spaces have been added to the style tags so that WordPress does not remove them.
Then modify the ConvertTo-HTML cmdlet to add the -Head parameter.
$message.Body = Get-ExchangeServer | Select-Object Name,ServerRole | ConvertTo-Html -Head $style
This time when the script is run the email looks like this instead.
That is a little better, but we can do a lot more. How about we add some more styles to the table and really make it look nice.
$style = "< style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "< /style>"
Again note that extra spaces were added to the style tags above to preserve them in WordPress.
Now the script produces an email that looks like this.
Although this requires you to know a little bit about how HTML styles work, it is a pretty easy topic to learn and once you get a few working styles in your scripting tool kit you can just use them over and over again.