April 28, 2005 at 3:40 pm
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?
April 28, 2005 at 7:16 pm
Post your code and maybe we can figure out what the problem is.
Aunt Kathi Data Platform MVP
Author of Expert T-SQL Window Functions
Simple-Talk Editor
April 29, 2005 at 10:17 am
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.
April 29, 2005 at 12:43 pm
....
While @@Fetch_Status = 0
BEGIN
Exec Master.dbo.xp_sendmail @MyRecipients, @MyMessage
Fetch Next From MyCursor Into @MyRecipients
End
....
Change the order
* Noel
April 29, 2005 at 12:53 pm
It works now. thanks. I'm happy now
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply