Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to send email from the stored procedure using xp_sendmail

Status
Not open for further replies.

venuchalla

Programmer
May 30, 2006
29
FR
Hello,
I am having a stored procedure through which I am sending an email using xp_sendmail and then updating a record in the database.
The update works fine but I am not able to receive the email from the stored procedure.

Could you please help me to receive the email from this stored procedure...


This is the stored procedure..

BEGIN
SET NOCOUNT ON
declare @CreatedByAlias varchar(50),
@expireat datetime,
@mailsent char(3),
@status varchar(10)
declare cur CURSOR for
select CreatedByAlias,expireat,mailsent,status
from Issues
where status = 'Open' and
DateDiff(minute,getdate(),expireat) = 30 and
mailsent ='No'
open cur
fetch next from cur into @CreatedByAlias,@expireat,@mailsent,@status
while @@FETCH_STATUS = 0
BEGIN
exec master.dbo.xp_sendmail @recipents=@CreatedByAlias,
@message=N'Reminder !!! This issue should be closed with in 30
minutes.' ;

Update Issues set mailsent ='Yes'
where CreatedByAlias = @CreatedByAlias and
expireat = @expireat and
mailsent = @mailsent and
status = @status

fetch next from cur into @CreatedByAlias,@expireat,@mailsent,@status
END

close cur
deallocate cur

------

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top