以前的开发人员有一个以电子邮件中的 html 表格形式发送电子邮件警报的过程,这是通过触发存储过程并传递相关参数来完成的。目前,这有点超出我的技能范围,但我正在尝试使用相同的程序来发送迟到的电子邮件。它在格式和布局方面工作得很好。查询是 -
SET @xml = CAST(( SELECT td = '<td align = "Center">' + CONVERT(VARCHAR(12),EmployeeName) + '</td>'
, td = '<td align = "Center">' + CONVERT(VARCHAR(12),StartTime) + '</td>'
, td = '<td align = "Center">' + CONVERT(VARCHAR(12),Late) + '</td>'
FROM #tempLateEmail
FOR XML PATH('tr'),TYPE).value('.','NVARCHAR(MAX)'
) AS NVARCHAR(MAX))
身体输出是:
SET @body =
N'<style type="text/css">'
+ 'body {font-family: Arial;font-size:12px;} '
+ 'table{font-size:11px; border-collapse:collapse;table-layout: fixed} '
+ 'td{ border:1px solid black; padding:3px;} '
+ 'th{background-color:#F1F1F1;border:1px solid black; padding:3px;}'
+ 'h1{font-weight:bold; font-size:12pt}'
+ 'h2{font-weight:bold; font-size:10pt}'
+ '</style>'
+ '<body style="width:620px; margin:15px;">'
+ '<div style="margin:0 auto; width:300px">'
+ '<h1>Lateness Email on' + ' ' + convert(varchar, getdate(), 103) + '</h1>'
+ '</div>'
+ '<div style="float:left; width:250px">'
+ '<p>The following people appear to have been late today</p> '
+ '</div>'
+ '<div style="float:left; margin-left:20px; width:250px">'
+ '<div style="height:150px; overflow:auto">'
+ '<table width="250px">'
+ '<tr>'
+ '<th width = 100>Employee</th>'
+ '<th width =100>Expected Start Date</th>'
+ '<th width =100>Minutes Late</th>'
+ '</tr>'
+ @xml
+ '</table>'
+ '</div>'
+ '</div>'
+ '<div style="clear:both;"></div>'
+ '</body>'
SET @subject = 'Lateness Email for - ' + convert(varchar, getdate(), 103)
然后它并排而不是在表格中输出它们。我理解它为什么这样做,但我不知道该怎么做。希望我提供了足够的信息