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
 General SQL Server Forums
 Database Design and Application Architecture
 HTML and DBmail

Author  Topic 

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2007-11-29 : 10:42:27

Is anyone using a SP or Trigger to Create a HTML formated e-mail and send it useing DBmail?

If so could I see a sample of the code?

Jim
Users <> Logic

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-29 : 10:52:56
SS2k5 only:

declare @ret int
EXEC @ret = msdb.dbo.sp_send_dbmail
@profile_name = 'put profile name',
@recipients = 'put recipients here',
@subject = 'put subject here',
@body = 'put html here'


you can easiliy put this in a trigger since this is an async operation and does not block the trigger.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2007-11-29 : 11:17:35
Then there should be no problem with creating the HTML dynamically and placing in a variable.
But how does it know that the body is HTML and not text?

Jim
Users <> Logic
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-29 : 11:35:41
@body_format = 'body_format'
Is the format of the message body. The parameter is of type varchar(20), with a default of NULL. When specified, the headers of the outgoing message are set to indicate that the message body has the specified format. The parameter may contain one of the following values:
TEXT
HTML
Defaults to TEXT.


so just add:
@body_format = 'HTML'


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2007-11-29 : 11:38:18
Thanks Mladen

Guess I will have to break down and buy a copy of ss2005.

Jim
Users <> Logic
Go to Top of Page
   

- Advertisement -