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: Tuesday, July 8, 2014 12:20 PM
Points: 24, Visits: 39

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: Thursday, August 7, 2014 11:40 AM
Points: 769, Visits: 246
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: Tuesday, July 8, 2014 12:20 PM
Points: 24, Visits: 39

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: Tuesday, May 6, 2014 5:51 AM
Points: 6,266, Visits: 2,028

....

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: Tuesday, July 8, 2014 12:20 PM
Points: 24, Visits: 39
It works now. thanks. I'm happy now
Post #178910
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse