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

Recommended Answers

All 3 Replies

Something like this?

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.