记录为空时的空白电子邮件(存储过程中的电子邮件)SQL Server2008 [英] Blank Email when record is null (email in stored proc) SQL Server2008

查看:97
本文介绍了记录为空时的空白电子邮件(存储过程中的电子邮件)SQL Server2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



如果记录空白,我想知道发送电子邮件是否有补救措施。然后,正在发送的电子邮件也是空白的。好像它在记录为NULL时没有完成html代码





  DECLARE   @ EmployeeName   nvarchar  150 ), @htmlBody   nvarchar (max)= N ' ' @ htmlheader   nvarchar (max), @htmlFooter   nvarchar (max)

set @ htmlheader = ' < html>< body>
< div style =padding:10px; width:677px>
< p style =font-size:14px; line-height:20px>< span style =color:red; font-weight:bold>添加/更新以下项目:其中/跨度>
< br />员工代码:'
+ cast( @ EmployeeNo as nvarchar 10 ))+ ' <峰; br />员工姓名:' + @ EmployeeName + '


< table style =font-size:9pt; border-collapse:collapse; width:100%cellpadding =3px>
< tr>
< td style =width:100px; background:#CCCCCC; font-weight:bold; border:1px solid#888888> Item< / td>
< td style =width:200px; background:#CCCCCC; font-weight:bold; border:1px solid#888888> Description< / td>
< td style =width:50px; background:#CCCCCC; font-weight:bold; border:1px solid#888888> Amount< / td>
< / tr>'


set @ htmlFooter = ' < / div>< / body>< / html>'

SELECT @htmlBody = @htmlBody + ' < tr>'
' < td style =border:1px固体#888888;>' + Item + ' < / td>'
' < td style =border:1px solid#888888;>' + ItemDesc + ' < / td>'
+ ' < td style =border:1px solid#888888;>' + Currency + ' ' + CONVERT ( nvarchar 20 ),cast(金额 as money ), 1 )+ ' < / td>< / tr>'
from 选择 *,( CASE WHEN Status = 2 然后 ' (更新)' 其他 ' ' end as StatuStr 来自 EmpPPInsurance 其中 EmployeeNo = @ EmployeeNo 状态 in 1 2 ))T1 order by Item


Set @htmlBody =替换( @htmlBody ' _ x0022 _'' '''
设置 @htmlBody =替换( @htmlBody ' _ x0023 _'' #'
设置 @htmlBody =替换( @htmlBody ' _ X00 3D _'' ='
设置 @htmlBody =替换( @htmlBody ' _ x003B _'' ;'
设置 @htmlBody =替换( @htmlBody ' _ x0020 _'' '

SET @ htmlBody = @ htmlheader + @htmlBody + ' < /表>' + @htmlFooter





我真的会如果有的话,感谢一个人可以帮我这个。



谢谢

解决方案

这取决于你的代码。因为你没有显示任何你不可能告诉你你做错了什么。



此外,为什么你会发送一封空白电子邮件?

Hi.

I wonder if there is a remedy in sending out an email , if the record is blank. Then the email that is being sent is also blank. Seems like it does not complete the html code when a record is NULL


DECLARE @EmployeeName nvarchar(150), @htmlBody nvarchar(max)=N'',@htmlheader nvarchar(max),@htmlFooter nvarchar(max)

set @htmlheader = '<html><body>
<div style="padding:10px;width:677px">
<p style="font-size:14px; line-height:20px"><span style="color:red;font-weight:bold">Following item/s are added/updated:</span>
<br/> Employee Code: '+ cast(@EmployeeNo as nvarchar(10))+'<br/> Employee Name:' + @EmployeeName +'

					
<table style="font-size:9pt;border-collapse:collapse;width:100%" cellpadding="3px">
<tr>
<td style="width:100px;background:#CCCCCC;font-weight:bold;border:1px solid #888888">Item</td>
<td style="width:200px;background:#CCCCCC;font-weight:bold;border:1px solid #888888">Description</td>
<td  style="width:50px;background:#CCCCCC;font-weight:bold;border:1px solid #888888">Amount</td>
</tr>'

set @htmlFooter ='</div></body></html>'
	
SELECT @htmlBody=@htmlBody + '<tr>'
'<td style="border:1px solid #888888;">' +Item+'</td>'
'<td style="border:1px solid #888888;">' +ItemDesc+'</td>'
+'<td style="border:1px solid #888888;">' +Currency +' '+ CONVERT(nvarchar(20),cast(Amount as money),1) +'</td></tr>'
from (Select *,(CASE WHEN Status=2 then '(updated)' else ''  end) as StatuStr from EmpPPInsurance where EmployeeNo =@EmployeeNo and Status in (1,2)) T1 order by Item

				
Set @htmlBody = Replace(@htmlBody, '_x0022_', '''')
Set @htmlBody = Replace(@htmlBody, '_x0023_', '#')
Set @htmlBody = Replace(@htmlBody, '_x003D_', '=')
Set @htmlBody = Replace(@htmlBody, '_x003B_', ';')
Set @htmlBody = Replace(@htmlBody, '_x0020_', ' ')
			
SET @htmlBody=@htmlheader + @htmlBody + '</table>' + @htmlFooter 	



I would really appreciate if someone could help me on this.

Thanks

解决方案

That depends on your code. Since you don't show any it's impossible to tell you what you're doing wrong.

Besides, why that hell would you send a blank email?


这篇关于记录为空时的空白电子邮件(存储过程中的电子邮件)SQL Server2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆