i not sure the datatype you have they so you may need to change it & you may need to join other table to get the email address to sent to the recipient
just gv a try here you may need tweak here and there
DECLARE C1 CURSOR READ_ONLY
FOR
Select * from ITHelpdesk.dbo.tickets
where TicketSTatusID <> 6
OPEN C1
FETCH NEXT FROM C1 INTO
@ticketsID,@requesterID,@SupportStaffID, @emailID
WHILE @@FETCH_STATUS = 0
BEGIN
mo meng
Contributor
6700 Points
1351 Posts
Re: Sending of email!
Apr 23, 2009 08:48 AM|LINK
i not sure the datatype you have they so you may need to change it & you may need to join other table to get the email address to sent to the recipient
just gv a try here you may need tweak here and there
DECLARE
@out_desc VARCHAR(1000),
@out_mesg VARCHAR(10)
DECLARE @ticketsID int,
@requesterID int,
SupportStaffID int,
emailID varchar(100)
DECLARE C1 CURSOR READ_ONLY
FOR
Select * from ITHelpdesk.dbo.tickets
where TicketSTatusID <> 6
OPEN C1
FETCH NEXT FROM C1 INTO
@ticketsID,@requesterID,@SupportStaffID, @emailID
WHILE @@FETCH_STATUS = 0
BEGIN
SET @body = '<table><tr><td>TicketID:</td><td>' + @ticketsID + '</td></tr>' +
'<tr><td>requesterID:</td><td>' + @requesterID + '</td></tr>' +
'<tr><td>SupportStaffID:</td><td>' + @SupportStaffID + '</td></tr></table>'
EXEC sp_send_mail
@emailID,
'xxxxxxx',
@email,
'Birthday Wishes',
@body,
'htmlbody',
@output_mesg = @out_mesg output,
@output_desc = @out_desc output
PRINT @out_mesg
PRINT @out_desc
FETCH NEXT FROM C1 INTO
@ticketsID,@requesterID,@SupportStaffID, @emailID
END
CLOSE C1
DEALLOCATE C1