System.Net.Mail.MailMessage does not recgonize "Cc"

Discussion in 'ASP.NET / ASP.NET Core' started by Merv Norton, Feb 8, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have an email Form that works correctly with two addressees. The following is the TRY block:
    try
    {
    msg = new MailMessage(txt_Email.Text,
    "[email protected],[email protected]", "Registration From: " + txt_First.Text + ' ' +
    txt_Last.Text,
    sb.ToString());
    msg.Cc.Add(txt_Email.Text);

    sc.Send(msg);
    Response.Redirect("confirm.aspx");
    }

    One of the fields in the Form is txt_Email.Text. When the Form does not contain the “msg.Cc,Add(txt_Email,Text); “ line of code, the Form works correctly. When I try to add the “msg.Cc,Add(txt_Email,Text); “ line of code I get the following error:
    Compiler Error Message: CS0117: 'System.Net.Mail.MailMessage' does not contain a definition for 'Cc'
    What is the problem and what is the solution?
     
  2. Not 100% sure but I think cc and bcc are MailAddress collection types. You cant add a string. Check msdn to confirm and find a sample.
     
  3. Bruce

    Bruce DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page