title: MIME Attachment Names containing Extended Characters Fails
body: <p>While working on a project that emails files with international filenames, I've come across an unusual issue. if I attach with a US-ASCII filename only, I can get better than 200 characters long without errors.</p>
  
  <p>If I include an extended character, it encodes in UTF-8 and the length before it gets funky is very small (&lt; 40 characters). To define funky.. here's an example filename after it goes bad:</p>
  
  <pre><code>=utf-8BSU5GT1JNw4FUSUNBX0ltcGFjdF9Bc3Nl
  </code></pre>
  
  <p>it looks like UTF8 encoded string with a UTF-8 decoding instruction or a mime boundary... not sure which.</p>
  
  <p>Has anyone seen this before -- and what are the rules / limitations of filenames -- I tried emailing the file by hand through outlook and it handles it, so I don't think it is a MIME specific limitation.</p>
  
  <p>Sample code:</p>
  
  <pre><code>class Program
  {
      private const string DOMAIN = "foobar.com";
      private const string SMTPHOST = "mail." + DOMAIN;
      private const string FROM = "chadwick.posey@" + DOMAIN;
      private const string TO = FROM;
  
      static void Main(string[] args)
      {
          MailMessage msg = new MailMessage(FROM, TO, "Subject", "Body");
  
          string path = Path.GetTempPath();
          string name = "AAAAAA_AAAAAAAAAAAA_AAAAAAA_AAAA - IIIIIII CCCCCCCCCC DD IIIIIIÁIIII_20111018_091327.pptx";
  
          File.WriteAllText(path + "\\" + name, "blah");
          Attachment att = new Attachment(path + "\\" + name, new ContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
  
          msg.Attachments.Add(att);
  
          SmtpClient client = new SmtpClient(SMTPHOST, 25);
          client.Send(msg);
      }
  }
  </code></pre>
  
  <p>I've tried (so far) -- setting the encoding for the attachment.NameEncoding to UTF8 and UTF32, neither worked. Setting the ContentDisposition.FileName on the attachment fails because it is not using US-ASCII characters only.</p>
  
  <p>Any suggestions on how to get it to include the full filename with the accent / extended characters in tact?</p>
  
  <p>Thanks
  Chadwick</p>