Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Send email to multiple people from database (asp.net2 c#)

Send email to multiple people from database (asp.net2 c#)

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasehelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AdamskiR
    wrote on last edited by
    #1

    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

    E A 2 Replies Last reply
    0
    • A AdamskiR

      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

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      something like: "select email from table" store results in a datatable for each row in database add result to your label or To textbox and use += for each row. that is a start anyway :)

      1 Reply Last reply
      0
      • A AdamskiR

        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

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • A Ashfield

          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

          A Offline
          A Offline
          AdamskiR
          wrote on last edited by
          #4

          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 - varchar

          Thanks Adam

          A 1 Reply Last reply
          0
          • A AdamskiR

            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 - varchar

            Thanks Adam

            A Offline
            A Offline
            Ashfield
            wrote on last edited by
            #5

            COALESCE simply takes the first nonnull value from the list given. You would do it as a bit of SQL, running on a connection/sql command, not a datasource, it just returns a single column. Hopefully this clarifies things

            Bob Ashfield Consultants Ltd

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups