如何使用 sp_send_dbmail 引用电子邮件正文中的参数值

How to reference parameter values in the email body using sp_send_dbmail

我正在尝试在电子邮件正文中包含一个参数值,但不确定该怎么做。我已经声明了参数,我想在电子邮件正文中使用 SHIFT_START 和 SHIFT_END。例如:

declare @Emails   nvarchar (100)
    declare @FullName  nvarchar (100)
    declare @ShiftStart  nvarchar (50)
    declare @ShiftEnd  nvarchar (50)

    DECLARE @EmailBody  VARCHAR(1000)
   set @EmailBody = N'<H1>Hello:</H1>' +
   N'you have indicated that your shift start was "PARAMETER VALUE HERE" and your shift end was "PARAMETER VALUE HERE" ' +
            N'<br>Please make sure.........' +
            N'<br>Thank You' +

您已经知道如何执行此操作,因为您已经在使用字符串连接(即“+”)运算符。

set @EmailBody = N'<H1>Hello:</H1>' +
   N'you have indicated that your shift start was ' + @ShiftStart + ' and your shift end was ' + @ShiftEnd + ' +
            N'<br>Please make sure.........' +
            N'<br>Thank You' +