how to send emails using triggers

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

how to send emails using triggers

 
0
  #1
Jul 2nd, 2007
hi every one,
iam a newbie in .net,i have a application in which i have to send email using triggers.can any one plz help, on how to configure sql mail .my application needs to delete rows on completion of expiry date and send the administrator email notifying it.
ok waiting for reply
bye
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,629
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: how to send emails using triggers

 
0
  #2
Jul 2nd, 2007
Something like this?
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to send emails using triggers

 
0
  #3
Jul 3rd, 2007
hi,
i want to elaborate wat exactly i want.trigger executes only after update or insert or delete occurs.i want to know how to delete rows even if the administrator didnt update or insert or didnt touch the datebase for few days,then aslo we should be able to delete rows and mails should be sent notifying the administrator about deleting rows.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 370
Reputation: greeny_1984 is an unknown quantity at this point 
Solved Threads: 29
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz

Re: how to send emails using triggers

 
0
  #4
Jul 3rd, 2007
my code is like this
CREATE TRIGGER [trg_job] ON [dbo].[JobPost]
FOR INSERT, UPDATE, DELETE
AS
set nocount on
declare @msg varchar(2000),
@postingdate nvarchar(50),
@applydays nvarchar(30),
@jobexpirydate nvarchar(30)
declare email_cur CURSOR
for
select postingdate,applydays,jobexpirydate from jobpost
where jobexpirydate = dateadd(dd, 2,getdate())
open email_cur
fetch next from email_cur into @postingdate, @applydays, @jobexpirydate
while @@Fetch_status=0
begin
set @msg='Dear row will be deleted'
exec master.dbo.xp_sendmail @recipients='xxx@yyy.com', @message=@msg,
@subject='delete Notification'
fetch next from email_cur into @postingdate, @applydays, @jobexpirydate
end
deallocate email_cur
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC