C# Web Help with sending E-mail to multiple recipients

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • npbaker1
    New Member
    • Mar 2008
    • 1

    C# Web Help with sending E-mail to multiple recipients

    I am not able to get an e-mail sent to multiple recipients. I am using C# in VS 2003.

    Here is the code:

    MailMessage mail = new MailMessage();
    mail.To = "address1@somew here.com;addres s2@somewhere.co m";
    mail.Cc="addres s3@somewhere.co m";
    mail.From = "My Program";
    mail.Subject = "Alert";
    mail.Priority = MailPriority.Hi gh;
    mail.BodyFormat = MailFormat.Text ;
    mail.Body = sMessage;
    SmtpMail.SmtpSe rver = "mymailserver.s omewhere.com";
    SmtpMail.Send(m ail);

    When using this the message gets sent to address1 and address3 but not address2. I have also tried using a comma in place of the semicolon with no luck. I am at a loss as I get no error message and everything I have looked up says that this is correct and should work. Any help would be apprectiated.

    Thanks
    Nate
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well the MSDN on that isn't very good since they obsoleted it.
    Their examples don't seem to lend it as a possibility that you can do multiple recipients though.
    However using trickery I found this:
    [QUOTE=MSDN for System.Web.Mail .MailMessage.To]
    Property Value
    A semicolon-delimited list of e-mail addresses.
    [/code]

    Are your addresses all valid?

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      This does work, I'd guess that Plater is right the problem is with the email address3. Try replacing it with your own - in fact you may want to ensure none of them are live or you may get accused of spamming :).

      Comment

      Working...