Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 setting body_format in SP_SEND_DBMAIL

Author  Topic 

Eyespi20
Starting Member

10 Posts

Posted - 2012-05-21 : 15:33:14
I have a trigger that fires based on customers to send them information. Some of my customers can receive HTML formatted email and some cannot. When I can, I like to send "pretty" emails with our company logo, etc, but for those customers who cannot receive HTML emails, I want to send them plain text emails. I've coded my trigger to separate these customers out and have a parameter @bf where I set the body format to 'TEXT' or 'HTML' as appropriate, however when I try to set the @Body_Format parameter in the sp_send_dbmail, it makes the HTML text regardless. I've checked the parameter and it does return HTML and TEXT for the appropriate customer, but the stored procedure simply ignores the parameter and sends everything plain text.

Can you not set this to a variable? I seem to be able to set all the other settings to a parameter successfully.


Margaret
    è¿é

Eyespi20
Starting Member

10 Posts

Posted - 2012-05-21 : 16:05:22
What I have ended up doing is adding an

IF @bf='HTML'
BEGIN

exec sp_send_DbMail
@body_format='HTML' etc etc

END

IF @bf='TEXT'
BEGIN

exec sp_send_DBMAIL
@body_format='TEXT', etc etc
END


to the trigger which is working a treat.

Still would like to know why @body_Format won't accept a parameter value though. It just seems strange to me.

Margaret
    è¿é
Go to Top of Page
   

- Advertisement -