Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to make Mail Body "BOLD" in SQL SERVER

Author  Topic 

ruchirj07
Starting Member

37 Posts

Posted - 2007-12-11 : 06:14:19
Hi,

I am using sql server procedure "sp_send_dbmail" for sending the mail. I want to make some part of the body "BOLD" to highlight it.

Is this possible in SQL SERVER. If yes, how?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-11 : 06:15:14
If you have enabled HTML content, use normal <b> ... </b> tag syntax.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

ruchirj07
Starting Member

37 Posts

Posted - 2007-12-11 : 06:16:41
How m i suppose the enable HTML content in sql server?
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-12-11 : 06:17:42
Yes make the @body_Format parameter 'HTML' and then in the body itself use html code that way the bold part can be between <STRONG> </STRONG> tags.


Duane.
Go to Top of Page

ruchirj07
Starting Member

37 Posts

Posted - 2007-12-11 : 06:20:59
Can you send me an example?
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2007-12-11 : 06:22:23
From Books OnLine.......
DECLARE @tableHTML NVARCHAR(MAX) ;

SET @tableHTML =
N'<H1>Work Order Report</H1>' +
N'<table border="1">' +
N'<tr><th>Work Order ID</th><th>Product ID</th>' +
N'<th>Name</th><th>Order Qty</th><th>Due Date</th>' +
N'<th>Expected Revenue</th></tr>' +
CAST ( ( SELECT td = wo.WorkOrderID, '',
td = p.ProductID, '',
td = p.Name, '',
td = wo.OrderQty, '',
td = wo.DueDate, '',
td = (p.ListPrice - p.StandardCost) * wo.OrderQty
FROM AdventureWorks.Production.WorkOrder as wo
JOIN AdventureWorks.Production.Product AS p
ON wo.ProductID = p.ProductID
WHERE DueDate > '2004-04-30'
AND DATEDIFF(dd, '2004-04-30', DueDate) < 2
ORDER BY DueDate ASC,
(p.ListPrice - p.StandardCost) * wo.OrderQty DESC
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' ;

EXEC msdb.dbo.sp_send_dbmail @recipients='danw@Adventure-Works.com',
@subject = 'Work Order List',
@body = @tableHTML,
@body_format = 'HTML' ;


Duane.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-11 : 06:27:06
I was going to say this is explained in Books Online, but is better.
No follow-up questions.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -