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 2005 Forums
 Transact-SQL (2005)
 Sending Email from Sql Job

Author  Topic 

rafeequddin_ahmed
Starting Member

23 Posts

Posted - 2008-07-10 : 08:01:33
HI,
I just heard that we can send e-mail but never work.need a help.

I have to send e-mail to my site registered users on every hourly,weekly and monthly basis.

conceptual wise i know how to do but technically I have very little idea.
I have to create multipe jobs that will initiated on different time.from each job I have to send mails.

but the content of the e-mails must be drived from the Query.Can i customize the result of the query.
any code example or good Link will be very much appreciate
1.Can we Initiate any job from asp.net without blocking.means it initiate the job and countinue without waiting for completion.

2.In the Job i have to check which are the latest record by taking out difference between current time -last job time and select all records in between and loop through this ,and get the user email i d for that and send a mail.
.
Thanks for any help.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-07-10 : 08:29:08
use an active script.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-07-10 : 08:39:01
quote:
Originally posted by sakets_2000

use an active script.


HOW??
Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2008-07-10 : 09:41:00
What version of SQL are you running? If you aren't running sql standard or enterprise edition, you may need to write your own. Please drop me a line at skillprover.com - we do this all the time using 2 methods, xp_smtp_sendmail and asp.net (System.net.mail). I will send you code...


>>>>> THE Whammy Bar String Trasher <<<<<
Go to Top of Page

rafeequddin_ahmed
Starting Member

23 Posts

Posted - 2008-07-10 : 10:05:10
quote:
Originally posted by danny2sweet

What version of SQL are you running? If you aren't running sql standard or enterprise edition, you may need to write your own. Please drop me a line at skillprover.com - we do this all the time using 2 methods, xp_smtp_sendmail and asp.net (System.net.mail). I will send you code...


>>>>> THE Whammy Bar String Trasher <<<<<


I am using Sql Server 2005 profession and asp.net 2.0.please provide the code here only if possible.
Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2008-07-10 : 10:14:15
Download and install xp_smtp_sendmail. No Microsoft Exchange is required. This will require port 25 for mail delivery only.

It's free and works a treat.

http://www.sqldev.net/xp/xpsmtp.htm

Put it in your sp jobs thus:

...
code
...
exec @i = xp_smtp_sendmail @server='127.0.0.1',@subject='this is a mail', @body='this is the body', @to='target.name@theirdomain.com'

There are other params too numerous to mention like from_name, from_email etc etc
Thx.

>>>>> THE Whammy Bar String Trasher <<<<<
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-12 : 00:08:14
Sql2k5 comes with db mail that uses smtp.
Go to Top of Page
   

- Advertisement -