email notification with multiple recipient and multiple attachment RRS feed

  • Question

  • How to send email with multiple recipient and multiple attachment?

    MailMessage mail = new MailMessage();

    mail.To.Add("someone1@company.com;someone2@company.com"); <---got error here

    one recipient can work but multiple can't.  Anyone know what's wrong?

    Monday, February 14, 2011 9:10 AM


All replies

  • Use a comma instead of ;

    MailMessage mail = new MailMessage();
    According to MailAddressCollection.Add  Multiple e-mail addresses must be separated with a comma character (","). If multiple e-mail addresses separated with a semicolon character (";") are passed in the addresses parameter. a FormatException exception is raised.

    MCTS, CodeProject MVP 2008
    • Marked as answer by Leo Liu - MSFT Monday, February 21, 2011 1:39 AM
    Monday, February 14, 2011 9:25 AM
  • Hello dear

    You can get your answer from this forum. I hope this links will help you







    Sankarshan Parida.Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    • Marked as answer by Leo Liu - MSFT Monday, February 21, 2011 1:39 AM
    Monday, February 14, 2011 9:30 AM
  • Hi htmlforums,

    Please review Sending Email Using C#

    How to Create a MailMessage Object?

    The MailMessage object has four different constructors that allow you to create a blank MailMessage; specify both the sender and recipient; or specify the sender, recipient, subject, and message body. If you are creating a simple message with a single recipient, you can do the bulk of the work in the MailMessage constructor:

    // C#

    MailMessage m = new MailMessage



    "Quarterl y data report. ",

    "See the attached spreadsheet. ");        


    You can specify the sender and the recipient as either a string or MailAddress object. The MailAddress object allows you to specify an e-mail address, a display name, and an encoding type, as the following code sample demonstrates:

    // C#

    MailMessage m = new MailMessage

    (new Mail Address("lance@contoso.com", "Lance Tucker") ,

    new Mail Address("ben@contoso.com", "Ben Miller") );



    Paras Sanghani


    Mark As Answer if it helped you.

    • Edited by Paras Sanghani Monday, February 14, 2011 10:34 AM Formatting
    • Marked as answer by Leo Liu - MSFT Monday, February 21, 2011 1:39 AM
    Monday, February 14, 2011 10:33 AM
  • thx for all your response..

    but i find that the sending is a bit slow, how to put a progressbar to show "sending in progress... " before a messagebox prompt "email has sent"?  do u have any sample on this?

    Wednesday, February 16, 2011 7:53 AM
  • You can use a BackgroundWorker component or use SendAsync method of the smptclient class to send it asynchronously.
    MCTS, CodeProject MVP 2008
    Wednesday, February 16, 2011 8:12 AM
  • If I have not got it wrong, you've got your original issue resolved, is that right?
    Please don't forget to mark answers to your orginal issue, or I will help you to perform this later.

    Your second requirement is about Winform development, so I recomment that you create a new thread in the following forum for better support:
    Windows Forms General Forum: http://social.msdn.microsoft.com/Forums/en-US/winforms/threads

    Whatevet, it is to the satisfaction of all if you can got your second issue resolved here.
    Thanks for your understanding.
    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 16, 2011 10:07 AM