title: C# Add attachment to mailmessage without knowing the extension
body: <p>A system generates files with different extensions.
  Those files have to be sent to an email address.</p>
  
  <p>How can I put a file in an attachment without knowing the extension</p>
  
  <p>For example "sample.xls" has to be added to the attachments but the application can also add "sample.txt", how do I handle that? I now have</p>
  
  <pre><code>attachment = new System.Net.Mail.Attachment(@"M:/" + filename + ".xls");
  </code></pre>
  
  <p>I want something like this</p>
  
  <pre><code>attachment = new System.Net.Mail.Attachment(@"M:/" + filename); // this didnt work
  </code></pre>
  
  <p>So that it sends any type of files. By the way, the filename isn't coming from code, but from a database without any extensions, so plain "sample" and it has to send the file with unknown extension, and it has to send it with the correct extension at the end.</p>
  
  <p>Help will be really appreciated!</p>