Send email to multiple people from database (asp.net2 c#)
-
Hi I am wanting to create a form that someone can send an email to a list of people being pulled out of my database, but struggling to work out how i can bring all the email addresses back? Is there a way that i can bring all of them back into a label/textbox and seperate them with a ; and use that for my To? Or would it be best to loop through the records? Any help would be appreciated. Regards Adam
-
Hi I am wanting to create a form that someone can send an email to a list of people being pulled out of my database, but struggling to work out how i can bring all the email addresses back? Is there a way that i can bring all of them back into a label/textbox and seperate them with a ; and use that for my To? Or would it be best to loop through the records? Any help would be appreciated. Regards Adam
-
Hi I am wanting to create a form that someone can send an email to a list of people being pulled out of my database, but struggling to work out how i can bring all the email addresses back? Is there a way that i can bring all of them back into a label/textbox and seperate them with a ; and use that for my To? Or would it be best to loop through the records? Any help would be appreciated. Regards Adam
This will give you a list of comma delimited email addresses (eg bob@a.co.uk, fred@abc.com, joe@khg.com)
DECLARE @EmailList varchar(1000)
SELECT @EmailList = COALESCE(@EmailList + ', ', '') + e.EmailAddress
FROM emailtable
WHERE .....SELECT @EmailList
Of course you may want to change froma comma to a semi-colon Hopefully this will help
Bob Ashfield Consultants Ltd
-
This will give you a list of comma delimited email addresses (eg bob@a.co.uk, fred@abc.com, joe@khg.com)
DECLARE @EmailList varchar(1000)
SELECT @EmailList = COALESCE(@EmailList + ', ', '') + e.EmailAddress
FROM emailtable
WHERE .....SELECT @EmailList
Of course you may want to change froma comma to a semi-colon Hopefully this will help
Bob Ashfield Consultants Ltd
-
Hi Thanks for your reply, unfortunatley not, ive not worked with COALESCE before and im not sure how you mean to go about putting this in my sqldatasource? The table is just made of 2 columns.
membersemail
id - int
email - varcharThanks Adam