我尝试通过 netezza存储过程内的邮件发送查询数据。 好像我可以通过shell命令发送邮件,但有没有办法通过存储过程本身发送邮件。
TIA:)
答案 0 :(得分:0)
您可以尝试使用此块SQLServer DB:
declare @table1 varchar(max)
set @table1 = cast (
(
select 2 [@cellpadding],
0 [@cellspacing],
1 [@border],
(
select (select convert(varchar, COL-1) for xml path('td'),type),
(select convert(varchar, COL-2) for xml path('td'),type),
(select convert(varchar, COL-3) for xml path('td'),type),
(select convert(varchar, COL-4) for xml path('td'),type),
(select convert(varchar, COL-5) for xml path('td'),type),
(select convert(varchar, COL-6) for xml path('td'),type)
from #updates
for xml path ('tr'),type
)
for xml path('table'), type
)
as varchar(max))
set @EmailRecipient = 'E-Mail Addresses'
set @MessageSubject = 'Subject'
set @MessageBody =
'<strong>'+@MessageSubject+'</strong><br><br>'+
@table1;
EXEC msdb..sp_send_dbmail @profile_name='Any Short Msg',
@recipients = @EmailRecipient,
@subject = @MessageSubject,
@body = @MessageBody,
@body_format = 'HTML';
以下是谷歌的一些链接,可能对此有所帮助。
https://www-304.ibm.com/connections/forums/html/topic?id=d2b1272b-9690-4b0b-ae0c-9e81bf4be444
https://www.talendforge.org/forum/viewtopic.php?id=27346
http://www.sqlteam.com/article/sending-smtp-mail-using-a-stored-procedure