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

时间:2015-03-07 16:51:33

标签: sql sql-server 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' +

1 个答案:

答案 0 :(得分:0)

您已经知道如何使用字符串连接(即“+”)运算符。

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' +