我正在努力向我们的客户发送有关他们可能很快会收到邮寄支票的信息。我想知道如何将支票号码信息放在电子邮件正文中,因为现在我正在生成一个表格,为他们提供汇款信息。
基本上我希望电子邮件的正文说
" Check num : 1234567 已发给您。到目前为止,我有以下查询
declare @docnum nvarchar(50)
declare @numatcard nvarchar(50)
declare @checknum nvarchar(50)
declare @checkAmt nvarchar(100)
declare @EMaIL nvarchar(200)
declare @Date nvarchar(200)
declare @table nvarchar(max)
declare @message nvarchar(Max)
declare @cardcode nvarchar(Max)
select
@docnum = t2.docnum,
@Cardcode=t3.cardcode,
@numatcard = t2.numatcard,
@checknum = t5.checknum,
@Checkamt= T5.CheckSum,
@EMAIL= T3.E_Mail ,
@Date=Convert(Nvarchar(12),T0.Docdate,101)
from
SAP_PROD.[dbo].[OVPM]T0 INNER JOIN SAP_PROD.[dbo].[VPM2] T1 ON T0.DocNum = T1.DocNum
left join SAP_PROD.[dbo].VPM1 T5 on T0.DocEntry=T5.docnum
left JOIN SAP_PROD.[dbo].OPCH T2 ON T1.DocEntry = T2.DocEntry And T1.InvType=T2.ObjType
left JOIN SAP_PROD.[dbo].ORPC T4 ON T1.DocEntry = T4.DocEntry And T1.InvType=T4.ObjType
left JOIN SAP_PROD.[dbo].ORIN T6 ON T1.DocEntry = T6.DocEntry And T1.InvType=T6.ObjType
left join SAP_PROD.[dbo].OCRD T3 on T3.CardCode=T0.CardCode
where T0.[DocDate]=CAST(getdate()-1 as date)
--and
--T5.CheckNum=32770
--T0.[DocDate]=CAST(getdate()as date)and t3.cardcode='CHIEF'
set @message ='<th><td>Dear Vendor,</th></td></br>
Check num : ' + @checknum + ' in the amount of ' + @checkAmt+ ' has been processed and will be mailed within 48 hours. Please see remittance information below.</br>
If you have any questions or concerns regarding this payment please contact a member of our Accounts Payable staff.</br></br>
Regards,</br>
</br>
Accounts Payable Department</br>
</br>
</br>
</p>'
DECLARE EmailCursor CURSOR FOR
Select @docnum, @Cardcode, @numatcard,@checknum,@checkAmt,@Checkamt,@EMAIL,@Date
from SAP_PROD.[dbo].[OVPM]T0 INNER JOIN SAP_PROD.[dbo].[VPM2] T1 ON T0.DocNum = T1.DocNum
left join SAP_PROD.[dbo].VPM1 T5 on T0.DocEntry=T5.docnum
left JOIN Solitude.SAP_PROD.[dbo].OPCH T2 ON T1.DocEntry = T2.DocEntry And T1.InvType=T2.ObjType
left JOIN SAP_PROD.[dbo].ORPC T4 ON T1.DocEntry = T4.DocEntry And T1.InvType=T4.ObjType
left JOIN SAP_PROD.[dbo].ORIN T6 ON T1.DocEntry = T6.DocEntry And T1.InvType=T6.ObjType
left join SAP_PROD.[dbo].OCRD T3 on T3.CardCode=T0.CardCode
where T0.[DocDate]=CAST(getdate()-1 as date)
OPEN EmailCursor
FETCH NEXT FROM EmailCursor INTO @docnum, @Cardcode, @numatcard,@checknum,@checkAmt,@Checkamt,@EMAIL,@Date
WHILE (@@FETCH_STATUS = 0)
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'abc',
@recipients=@email,
@subject = 'Remittance',
@body = @message,
@body_format = 'HTML'
FETCH NEXT FROM EmailCursor INTO @docnum, @Cardcode, @numatcard,@checknum,@checkAmt,@Checkamt,@EMAIL,@Date
END
Close EmailCursor
Deallocate EmailCursor