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 2000 Forums
 Transact-SQL (2000)
 Automating email in sql server

Author  Topic 

gamaz
Posting Yak Master

104 Posts

Posted - 2009-01-12 : 11:19:00
Hi,
The following is a sample table of my application



Name EmailAddress CaseID StartDate DueDate CloseDate

Jane Doe jane.doe@test.com 2122 1/1/09 1/4/09

Tim Jones tim.jones@test.com 3267 1/3/08 1/5/09

Robert Stil robert.still@test.com 1324 1/2/09 1/4/09

Jane Doe jane.doe@test.com 3345 1/1/09 1/4/09 1/4/09

Jane Doe jane.doe@test.com 2454 1/1/09 1/2/09

Robert Stil robert.still@test.com 7867 1/2/09 1/3/09

Tim Jones tim.jones@test.com 2345 1/3/08 1/5/09 1/3/09

Jane Doe jane.doe@test.com 2989 1/1/09 1/4/09



Now I have the following rule:

If CloseDate is not null and CurrentDate - DueDate > 5 then each of the person should receive an email stating the

corresponding case is still not closed.

After three days from an email being sent if the closedate is still null for a particular case then another email need to be

sent stating that CloseDate is still open.


Now I need to automate this email notification process via SQL Server.

I would like to know what is the best way to handle this in sql as there are differnt ways to handle this.

Also, what is the best way to handle the above business rule for email automation - stored proc, query etc.

I appreciate any resolution for this. Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-12 : 12:14:11
the email can be sent using xp_sendmail extended stored procedure or by using send mail task in DTS
the best way to handle the business rule is to write an procedure. inside that call xp_sendmail to send mails
Go to Top of Page

gamaz
Posting Yak Master

104 Posts

Posted - 2009-01-12 : 12:26:17
Thanks visakh16 for your helpful reply. So you are advising to use sqlmail instead of using sqlagentmail.

Could you send me any helpful link with some concept/example to get me started. Thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-12 : 12:36:17
quote:
Originally posted by gamaz

Thanks visakh16 for your helpful reply. So you are advising to use sqlmail instead of using sqlagentmail.

Could you send me any helpful link with some concept/example to get me started. Thanks.


i was just giving you one of options. SQLAgentmail can also be used.

http://www.databasejournal.com/features/mssql/article.php/10894_3345091_1/SQL-MAIL-and-SQL-Agent-Mail-using-POP3-and-SMTP.htm
Go to Top of Page
   

- Advertisement -