1

i have a simple script that sends emails to our users.

I have no problem sending the emails but what bothers me that i have to specify the "TO" field.. so each user that receives an email as a BCC can see the to field ("admin@domain.com") which is the same as the "From" field.

Basically want i want to have is each user in the bcc field see their own email address instead of "admin@domain.com" as the to field.

Here's my code so far

    MailMessage mm = new MailMessage("admin@domain.com", "admin@domain.com", this.txtSubject.Text, this.txtBodyHtml.Text);
    mm.IsBodyHtml = true;

    // go through records and add them to email list
    while (rs.Read()){
        mm.Bcc.Add(new MailAddress(rs["Email"].ToString(), rs["FullName"].ToString()));
    }

    SmtpClient mailClient = new SmtpClient();

    try{
        //Send the email asynchronously
        mailClient.SendAsync(mm, null);
    }catch (SmtpException smtpEx){
        //sendErrors.Add(smtpEx.InnerException.Message);
        //throw smtpEx;
    }catch (Exception ex){
        //sendErrors.Add(ex.Message);
        //throw ex;
    }
robert
  • 1,523
  • 5
  • 19
  • 27
  • Is there some reason you can't send each user an individual email? – Matt Mills Jun 16 '12 at 00:57
  • @arootbeer : I imagine that's probably the only answer. – spender Jun 16 '12 at 01:09
  • 1
    This might not be the direct answer, but have a look here. You will need to send individual emails if you want TO field to show individual addresses. http://stackoverflow.com/questions/302271/sending-mail-via-smtp-in-c-sharp-using-bcc-without-to – Alex S Jun 16 '12 at 05:29

0 Answers0