title: ATT00006.dat file autmatically attached in mail attachment
body: <p>I have a page that have fileupload control, on the submission of the form, when the fileupload control has file, file is sent via attachment in a mail and working absulutly fine, but when the fileupload control does not have file, <strong>ATT00006.dat</strong> file is automatically sent via email attachment.</p>
  
  <p>Reference URL: <a href="http://nextech.pk/Enquiry.aspx?Enq=cu" rel="nofollow noreferrer">http://nextech.pk/Enquiry.aspx?Enq=cu</a></p>
  
  <p>Advance Thanks for any help</p>
  
  <p><strong>Edit -- Code:</strong></p>
  
  <pre><code> hpf = fup1.PostedFile;
      String toEmail = "test@hotmail.com";
      String fromEmail = "mailer@hotmail.com";
      MailMessage objMail = new MailMessage(fromEmail, toEmail);
      objMail.IsBodyHtml = true;
  
      StringBuilder MailBody = new StringBuilder();
  
      MailBody.Append("&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt; &lt;br&gt;");
      MailBody.Append("&lt;br&gt;" + "An enquiry is filed &lt;br&gt;&lt;br&gt;");
      MailBody.Append("&lt;strong&gt;&lt;u&gt;Enquirer Information&lt;/u&gt;&lt;/strong&gt;" + "&lt;br&gt;&lt;br&gt;");
      MailBody.Append("&lt;strong&gt;Contact Name:&lt;/strong&gt;&amp;#09;" + txtFirstName.Text + "&lt;br&gt;");
      MailBody.Append("&lt;strong&gt;Email:&lt;/strong&gt;&amp;#09;&amp;#09;&amp;#09; " + txtEmail.Text + "&lt;br&gt;");
      MailBody.Append("&lt;strong&gt;Institute:&lt;/strong&gt;&amp;#09;&amp;#09; " + txtInstitute.Text + "&lt;br&gt;");
      MailBody.Append("&lt;strong&gt;Phone #:&lt;/strong&gt;&amp;#09;&amp;#09; " + txtPhone.Text + "&lt;br&gt;");
  
      MailBody.Append("&lt;br&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;br&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; " + txtEnquiry.Text + "&lt;br&gt;");
  
      if (hpf != null)
      {
          MailBody.Append("&lt;br&gt;" + "This email also contains an attachment:- &lt;Strong&gt;(" + hpf.FileName + ")&lt;/Strong&gt;&lt;br&gt;");
      }
  
      MailBody.Append("&lt;/body&gt;&lt;/html&gt;");
      objMail.Body = MailBody.ToString();
      if (hpf != null)
      {
          System.IO.Stream inputStream = hpf.InputStream;
          String fileName = hpf.FileName;
          Attachment attach = new Attachment(inputStream, fileName);
  
          objMail.Attachments.Add(attach);
      }
      SmtpClient SmtpClnt = new SmtpClient();
      SmtpClnt.Send(objMail);
  </code></pre>