Reputation:
i want to develop an application where need to set reminder and send mail through database on particular time duration.
Upvotes: 2
Views: 2109
Reputation: 505
These examples are from here:
Sending an e-mail message
This example sends an e-mail message to Dan Wilson using the e-mail address [email protected]. The message has the subject Automated Success Message. The body of the message contains the sentence 'The stored procedure finished successfully'.
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'AdventureWorks Administrator', @recipients = '[email protected]', @body = 'The stored procedure finished successfully.', @subject = 'Automated Success Message' ;
Sending an e-mail message with the results of a query
This example sends an e-mail message to Dan Wilson using the e-mail address [email protected]. The message has the subject Work Order Count, and executes a query that shows the number of work orders with a DueDate less than two days after April 30, 2004. Database Mail attaches the result as a text file.
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'AdventureWorks Administrator', @recipients = '[email protected]', @query = 'SELECT COUNT(*) FROM AdventureWorks.Production.WorkOrder WHERE DueDate > ''2004-04-30'' AND DATEDIFF(dd, ''2004-04-30'', DueDate) < 2' , @subject = 'Work Order Count', @attach_query_result_as_file = 1 ;
Upvotes: 0
Reputation: 31
Please goto the following links for sending Email using SqlServer 2005
http://www.sqlservercurry.com/2008/02/how-to-send-email-using-sql-server-2005.html
Upvotes: 0
Reputation: 41889
Use SQL Server Database Mail.
http://technet.microsoft.com/en-us/library/ms175887(SQL.90).aspx
You can then create the process logic that calls the stored procedure sp_send_dbmail in order to send mail.
You can then schedule your process/stored procedure using a SQL Server Agent job.
Upvotes: 1