Site Search:
Sign in | Join | Help
4Penny.net

SQL Server (T-SQL)

Comments and notes on SQL Server 2000, 2005, and T-SQL

Mail from a stored procedure in SQL 2005

Code to send mail from a sql 2005 stored proc will look something like this:

declare @body1 varchar(100)
set @body1 = 'Server :'+@@servername+ ' My First Database Email '
EXEC msdb.dbo.sp_send_dbmail @recipients='steve@4penny.net',
    @subject = 'My Mail Test',
    @body = @body1,
      @profile_name = 'db mail account',
    @body_format = 'HTML' ;

 

Comments

 

srinivas said:

hi i have one custom stored procedure. how can i execute this stored procedure in sp_send_dbmail . can any one pls help me.....

September 18, 2007 6:35 AM [Delete]
 

Steve Gray said:

This post is really just my reminder of what the code should like like. This post

vstoolsforum.com/.../configuring-sql-database-mail-on-a-sql-2005-server.aspx

Is a walk through setting up mail on SQL. Does that help.

September 18, 2007 9:02 AM [Delete]
 

Patty said:

I know this is an old post but I do not see the answer to Srinivis's comment.

I have the same problem - would like to execute a custom stored proc  with params IN the cb_sp_send_dbmail.

Do you know the syntax?

June 13, 2008 1:09 PM [Delete]

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.