Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

xp_sendmail to multiple recipients Expand / Collapse
Author
Message
Posted Thursday, April 28, 2005 3:40 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 7:19 AM
Points: 24, Visits: 43

I'm trying to send email to a group of people using the logic provided by following article:  http://www.sqlservercentral.com/columnists/kdas/xp_sendmail.asp

However, I can only send out one email.  If I retrieved more than one email addresses, it won't work even though it shown "Mail Sent" multiple times.  What did I do wrong?

Post #178511
Posted Thursday, April 28, 2005 7:16 PM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Yesterday @ 10:44 AM
Points: 769, Visits: 258
Post your code and maybe we can figure out what the problem is.

Aunt Kathi
Microsoft
(Former SQL Server MVP)
Post #178539
Posted Friday, April 29, 2005 10:17 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 7:19 AM
Points: 24, Visits: 43

Here is my code:

########################################

Declare @MyMessage nvarchar (255)

Set @MyMessage = 'Sent out emails'

Declare MyCursor Cursor For

Select email From fs_users  Where user_id < 35

Open MyCursor

Fetch Next From MyCursor Into @MyRecipients

While @@Fetch_Status = 0

BEGIN

Fetch Next From MyCursor Into @MyRecipients

Exec Master.dbo.xp_sendmail @MyRecipients, @MyMessage

End

Close MyCursor

Deallocate MyCursor

########################################

 

Also, when I hard-coded multiple email addresses, it went out ok.

Post #178852
Posted Friday, April 29, 2005 12:43 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, November 21, 2014 6:34 AM
Points: 6,259, Visits: 2,031

....

While @@Fetch_Status = 0

BEGIN

Exec Master.dbo.xp_sendmail @MyRecipients, @MyMessage

Fetch Next From MyCursor Into @MyRecipients

End

....

 

Change the order

 




* Noel
Post #178909
Posted Friday, April 29, 2005 12:53 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 7:19 AM
Points: 24, Visits: 43
It works now. thanks. I'm happy now
Post #178910
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse