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.
| Author |
Topic |
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-08-15 : 06:57:22
|
| Does anyone know how to send email automatically.I have records in a table that contains a date added. I want that when todays date is 10 days past the date added in the table that an email will be sent off to the person who added the record. The persons email address is also stored in the table along with the record they added.I know the code to use to send an email but what I don't know is how do you schedule the code to kick off to check the dates and to then send off the email.anyone any ideas?macca |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-08-15 : 07:28:55
|
| There are several ways of doing it: - create a stored procedure that reads the required records and calls xp_sendmail. Then schedule it via SQL Agent - create a DTS package which contains a send mail task. Also schedule this by sql agent - create a vbscript script file that does what you want. Schedule using SQL Agent or NT task scheduler - create a proper EXE in VB/C/whatever, read the database and send the mails using the CDO COM objectsMy personal preference (and I would guess most people here) would be to go with the 4th option. The functionality for sending mail in SQL is not perfect, and you would have more control if you wrote the app yourself. HTH,Tim |
 |
|
|
macca
Posting Yak Master
146 Posts |
Posted - 2005-08-15 : 08:32:52
|
| Thanks for the reply Timmy.I have worked this out, i'm reading the values into a temporary table and then I am kicking off a VB.exe using the scheduler and the VB sends a mail to the recipients.macca |
 |
|
|
|
|
|