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
 General SQL Server Forums
 New to SQL Server Programming
 HTML table in email samples?

Author  Topic 

Rasta Pickles
Posting Yak Master

174 Posts

Posted - 2013-06-01 : 10:04:48
Has anyone got any sample code for generating a professional looking table that will be emailed?

I've created something myself and, as a first attempt, I'm quite pleased with it but I'm sure someone has something a lot more pleasing to the eye.

FWIW, my table code follows and for those of you who can interpret it, you can see it's functional but there are no bells and whistles

SET @tableHTML = N'
<style type = ''text/css''>' + N'
table { cellpadding:16px; border:1px double #e3e3e3; font:11pt; }' + N'
table td, table th { padding: 5px; color: #333; }' + N'
table caption { border:1px double #e3e3e3; font-variant:small-caps; font-weight:bold; }' + N'
table th { font-variant:small-caps; font-weight:bold; border-bottom: 1px solid #e3e3e3; border-top: 1px solid #e3e3e3; }' + N'
table td { border-bottom: 1px solid #e3e3e3; border-top: 1px solid #e3e3e3; }' + N'
</style>' + N'
<table>' + N'
<caption>Files not updated as part of the overnight load</caption>' + N'
<tr><th>File No</th>
<th>File Name</th>
<th>Last Modified Date</th>
<th>Last Modified Time</th></tr>' +
CAST ((SELECT td = FileNo, '', td = FileName, '', td = DateMod, '', td = TimeMod, ''
FROM logfile ORDER BY DateMod, TimeMod
FOR XML PATH('tr'), TYPE) AS NVARCHAR(MAX)) + N'</table>'


Thanks for any input!

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2013-06-01 : 12:15:03
This might give you some help

http://www.mssqltips.com/sqlservertip/2347/send-email-in-a-tabular-format-using-sql-server-database-mail/

mohammad.javeed.ahmed@gmail.com
Go to Top of Page
   

- Advertisement -