I have this piece of code which creates an attachment and sends email. If name of the file contains æ, ø or æ, the name is totally destroyed.
If I remove norwegian letters, everything is ok
var stream = new MemoryStream();
doc.Save(stream, SaveFormat.Docx);
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.IsBodyHtml = true;
mail.Subject = "Attachments test";
mail.Body = "Hei,<br /><br />";
stream.Seek(0, SeekOrigin.Begin);
var attachment = new Attachment(stream, "Name Å Æ Ø.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
attachment.NameEncoding = Encoding.UTF8;
mail.Attachments.Add(attachment);
var smtp = new SmtpClient("smtp.server.com") {Port = 25};
smtp.Send(mail);
How to get this work properly?
SOLUTION
I found a solution here http://social.msdn.microsoft.com/Forums/en-US/dotnetframeworkde/thread/b6c764f7-4697-4394-b45f-128a24306d55
here is resolution from microsoft for .net framework 4
http://support.microsoft.com/kb/2402064
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With