Single email to multiple recipients

Discussion in 'ASP .Net' started by .Net Newbie, Jun 30, 2004.

  1. .Net Newbie

    .Net Newbie Guest

    Hello,

    I am currently coding my ASP.Net pages in c# and have run into a question
    concerning Emails. I have four objects on a page (six including 2 buttons).
    The first is a subject line (textbox) , the next is the email body (a
    Textbox with multiple rows), an email address (textbox), and a DropDownList
    containing multiple email addresses (populated from a SQL Server table).
    The way this page functions is that a user types in the email subject and
    body in two of the textboxes. The user can then enter additonalal email
    addresses into the single email address textbox and upon pushing a button
    the email address is validated and added to the DropDownList (if it's
    valid). Upon clicking another button the information is currently being
    added to a SQL Server table. I would also like to send this message to each
    email address in the DropDownList. I have successfully gotten this to work
    when I use one email address but the code chokes when I have multiple email
    addresses or actually only sends the information to the first recipient. My
    code so far is as follows:
    // Table insert (try)
    ListItem[] myListItemArray = new ListItem[Assigned.Items.Count];
    Assigned.Items.CopyTo(myListItemArray, 0);
    foreach(ListItem i in myListItemArray){
    MailMessage mailMsg = new MailMessage();
    mailMsg.From ="";
    if (i.Value == null){
    mailMsg.To = i.Text;
    } else {
    mailMsg.To = i.Value;
    }
    mailMsg.Subject = caseStyle.Text + " : " + NoteTitle.Text;
    mailMsg.Body = NoteBody.Text;
    SmtpMail.SmtpServer = "localhost";
    SmtpMail.Send(mailMsg);
    }
    // catch etc here

    If anyone can assist me with how to send an email to multiple recipients
    while reading the information from a DropDownList, I would greatly
    appreciate it.

    Thanks,
    Jeff
     
    .Net Newbie, Jun 30, 2004
    #1
    1. Advertising

  2. Maybe this example is useful for you.
    http://www.aspfree.com/c/a/ASP Code...le-recipients-using-addresses-from-a-database

    --
    FF
    www.francofigun.com.ar
    www.microsofties.com.ar
    MSN:
    UIN: 314408886
    Yahoo MSN:

    ".Net Newbie" <> escribió en el mensaje
    news:e$...
    > Hello,
    >
    > I am currently coding my ASP.Net pages in c# and have run into a question
    > concerning Emails. I have four objects on a page (six including 2

    buttons).
    > The first is a subject line (textbox) , the next is the email body (a
    > Textbox with multiple rows), an email address (textbox), and a

    DropDownList
    > containing multiple email addresses (populated from a SQL Server table).
    > The way this page functions is that a user types in the email subject and
    > body in two of the textboxes. The user can then enter additonalal email
    > addresses into the single email address textbox and upon pushing a button
    > the email address is validated and added to the DropDownList (if it's
    > valid). Upon clicking another button the information is currently being
    > added to a SQL Server table. I would also like to send this message to

    each
    > email address in the DropDownList. I have successfully gotten this to work
    > when I use one email address but the code chokes when I have multiple

    email
    > addresses or actually only sends the information to the first recipient.

    My
    > code so far is as follows:
    > // Table insert (try)
    > ListItem[] myListItemArray = new ListItem[Assigned.Items.Count];
    > Assigned.Items.CopyTo(myListItemArray, 0);
    > foreach(ListItem i in myListItemArray){
    > MailMessage mailMsg = new MailMessage();
    > mailMsg.From ="";
    > if (i.Value == null){
    > mailMsg.To = i.Text;
    > } else {
    > mailMsg.To = i.Value;
    > }
    > mailMsg.Subject = caseStyle.Text + " : " + NoteTitle.Text;
    > mailMsg.Body = NoteBody.Text;
    > SmtpMail.SmtpServer = "localhost";
    > SmtpMail.Send(mailMsg);
    > }
    > // catch etc here
    >
    > If anyone can assist me with how to send an email to multiple recipients
    > while reading the information from a DropDownList, I would greatly
    > appreciate it.
    >
    > Thanks,
    > Jeff
    >
    >
     
    Franco Figún, Jun 30, 2004
    #2
    1. Advertising

  3. .Net Newbie

    .Net Newbie Guest

    Franco,

    I got it working using the emample in this article. Thanks for the nudge in
    the right direction.

    -Jeff

    "Franco Figún" <> wrote in message
    news:...
    > Maybe this example is useful for you.
    >

    http://www.aspfree.com/c/a/ASP Code...le-recipients-using-addresses-from-a-database
    >
    > --
    > FF
    > www.francofigun.com.ar
    > www.microsofties.com.ar
    > MSN:
    > UIN: 314408886
    > Yahoo MSN:
    >
    > ".Net Newbie" <> escribió en el mensaje
    > news:e$...
    > > Hello,
    > >
    > > I am currently coding my ASP.Net pages in c# and have run into a

    question
    > > concerning Emails. I have four objects on a page (six including 2

    > buttons).
    > > The first is a subject line (textbox) , the next is the email body (a
    > > Textbox with multiple rows), an email address (textbox), and a

    > DropDownList
    > > containing multiple email addresses (populated from a SQL Server table).
    > > The way this page functions is that a user types in the email subject

    and
    > > body in two of the textboxes. The user can then enter additonalal email
    > > addresses into the single email address textbox and upon pushing a

    button
    > > the email address is validated and added to the DropDownList (if it's
    > > valid). Upon clicking another button the information is currently being
    > > added to a SQL Server table. I would also like to send this message to

    > each
    > > email address in the DropDownList. I have successfully gotten this to

    work
    > > when I use one email address but the code chokes when I have multiple

    > email
    > > addresses or actually only sends the information to the first recipient.

    > My
    > > code so far is as follows:
    > > // Table insert (try)
    > > ListItem[] myListItemArray = new ListItem[Assigned.Items.Count];
    > > Assigned.Items.CopyTo(myListItemArray, 0);
    > > foreach(ListItem i in myListItemArray){
    > > MailMessage mailMsg = new MailMessage();
    > > mailMsg.From ="";
    > > if (i.Value == null){
    > > mailMsg.To = i.Text;
    > > } else {
    > > mailMsg.To = i.Value;
    > > }
    > > mailMsg.Subject = caseStyle.Text + " : " + NoteTitle.Text;
    > > mailMsg.Body = NoteBody.Text;
    > > SmtpMail.SmtpServer = "localhost";
    > > SmtpMail.Send(mailMsg);
    > > }
    > > // catch etc here
    > >
    > > If anyone can assist me with how to send an email to multiple recipients
    > > while reading the information from a DropDownList, I would greatly
    > > appreciate it.
    > >
    > > Thanks,
    > > Jeff
    > >
    > >

    >
    >
     
    .Net Newbie, Jul 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley
    Replies:
    2
    Views:
    863
    Paul Wright
    Jul 1, 2004
  2. Replies:
    1
    Views:
    386
    Rene Pijlman
    Feb 20, 2006
  3. dmiller23462

    Multiple Email Recipients depending on Value

    dmiller23462, Oct 28, 2004, in forum: ASP General
    Replies:
    4
    Views:
    249
    dmiller23462
    Nov 16, 2004
  4. Logesh Subramani

    Sending email to multiple recipients

    Logesh Subramani, Aug 5, 2008, in forum: Ruby
    Replies:
    1
    Views:
    145
    James Britt
    Aug 5, 2008
  5. Joseph Clark
    Replies:
    2
    Views:
    238
    Dave Lilley
    Oct 14, 2010
Loading...

Share This Page