I create a procedure to send automatic emails. The email gets to the address and everything seems working fine but the body can not be seen. I’m using sql 2005 and MS exchange server 2007. The part of the procedure that writes the body is as follow.
declare @bodymsg as varchar(1000)
set @bodymsg = 'The application '
set @bodymsg = @bodymsg + @appnum
set @bodymsg = @bodymsg + ' have been auto assign to you by the call center auto assign program.'
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'The borrower information is as follow:'
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'Name: '
set @bodymsg = @bodymsg + @borrower
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'Email: '
set @bodymsg = @bodymsg + @borremail
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'Phone: '
set @bodymsg = @bodymsg + @borrhome
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'Cellphone: '
set @bodymsg = @bodymsg + @borrcell
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + CHAR(13)
set @bodymsg = @bodymsg + 'Please contact the borrower ASAP.'
execute [msdb].[dbo].[sp_send_dbmail]
@profile_name = 'CallCenter',
@recipients = @email,
@subject = @subjectmsg,
@body = @bodymsg,
@body_format = 'TEXT'
Just before you execute the sp_send_dbmail PRINT the @bodymsg parameter out so that you know the data has been built correctly.
e.g.
As you passing a number of parameters to it one of them could be setting the @bodymsg to NULL