Usually the content of emails is sent by Database Mail in a plain text. You can change it to HTML format for a richer content. This article demonstrates how to do it.
The article here is assumed that a SQL Database Mail profile “MailProfile1′ has been created. The MailProfile1 tells Database Mail what account it should use to send emails. For how to create a Database Mail profile, you can refer to the previous post SQL Database Mail – Send Emails from SQL Server.
Here is the example to send emails in HTML format.
— Start T-SQL
@profile_name = ‘MailProfile1’,
@recipients = ‘firstname.lastname@example.org’,
@subject = ‘HTML Format’,
@body_format = ‘HTML’,
@body = ‘<html><body><p>An html link to www.bing.com is embedded in this email. The link is here: <a href=”http://www.bing.com”>u bing?</a></p></body></html>’
— End T-SQL —
The recipient will receive an email like the following one.
From: Yuhong Li
Sent: Wednesday, January 05, 2011 12:09 PM
To: Some One
Subject: HTML Format
An html link to www.bing.com is embedded in this email. The link is here: u bing?
Click on the word “u bing?” in the email, it will redirect readers to http://www.bing.com.
For more information about sending emails, see sp_send_dbmail in MSDN documents.
<END OF POST>