SQL JOB电子邮件发送 [英] Sql JOB email sending
本文介绍了SQL JOB电子邮件发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用SQL JOB发送计划的电子邮件.
我使用的存储过程是sp_send_dbmail
问题是我可以将邮件正文作为HTML发送吗?
即,我想在该电子邮件的正文中添加超链接.
我该怎么办?
I am using SQL JOB to send scheduled e mails.
The Stored Procedure i using is sp_send_dbmail
the question is can i send body of the mail as HTML
ie, i want to add a hyperlink in the body of that email.
How can i do this?
Declare
@Invoice_Status varchar(50),
@Invoice_Purchaser varchar(50),
@Username varchar(50),
@Email varchar(50),
@Mail_Body nvarchar(50)
Declare d Cursor
for
select Invoice_Purchaser,email,Invoice_Status from tbl_local_Invoices tl,tbl_User tu where tl.Invoice_Status collate SQL_Latin1_General_CP1_CI_AS='SENT' and tl.Invoice_Purchaser collate SQL_Latin1_General_CP1_CI_AS=tu.username collate SQL_Latin1_General_CP1_CI_AS group by tl.Invoice_Purchaser,tu.email,tl.Invoice_Status
open d
first:Fetch next from d into
@Invoice_Purchaser,@Email,@Invoice_Status
While @@FETCH_STATUS=0
begin
if @Invoice_Status <>'SENT'
goto jump
use msdb
Begin
if @Email <>''
SET @Mail_Body =
'<a href="http://www.yahoo.com">What ever text that you want to be colored goes here</a>'
EXEC sp_send_dbmail
@profile_name='Divoli Data Processing',
@recipients=@Email,
@subject='DIA Invoice Approval Reminder',
@body=@Mail_Body
End --Mail Send End
goto first
End -- While End
jump:
close d
Deallocate d
我使用的代码在上面,但未正确显示
请帮助我
The code i used is above, but its not showing correctly
Please help me
推荐答案
在文章下方的链接中看到
seen in the link below the article
From SQL Server
Microsoft claims this is a limitation of MAPI, but I seem to recall that Outlook uses MAPI, and it has no problems sending HTML mail. For more details, see Question #10 from KB #311231, as well as KB #268440.
If you are using XP_SMTP_SendMail, you can use the @type parameter to specify text/html format.
EXEC master.dbo.xp_smtp_sendmail
@server = 'smtp.yourdomain.com',
@from = 'you@yourdomain.com',
@to = 'them@theirdomain.com',
@subject = 'HTML Testing...',
@type = 'text/html',
@body = '<a href=#>foo</a>'
查看完整的详细信息: http://classicasp.aspfaq. com/email/how-do-i-send-e-mail-in-html-format.html [
see full details: http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-in-html-format.html[^]
这篇关于SQL JOB电子邮件发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文