title: Error CS1729: 'Attachment' does not contain a constructor that takes 2 arguments
body: <p>I am trying to send mail with attachment through smtp protocol, so I found this tutorial in <a href="http://csharpdotnetfreak.blogspot.com/2009/10/send-email-with-attachment-in-aspnet.html" rel="nofollow">http://csharpdotnetfreak.blogspot.com/2009/10/send-email-with-attachment-in-aspnet.html</a>. And tried the following simple coding, the object got created correctly for attachment but it tell me the error that does not take 2 arguments.</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Configuration;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using System.Net.Mail;
  
  public partial class composemail : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  }
  protected void SendMail()
  {
      MailMessage mail = new MailMessage();
      mail.To.Add(YourEmail.Text);
      mail.From = new MailAddress(YourName.Text);
      mail.Subject = YourSubject.Text;
      mail.Body = Comments.Text;
      mail.IsBodyHtml = true;
      if (FileUpload1.HasFile)
      {
          mail.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName));
      }
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
      SendMail();
  }
  }
  </code></pre>