-
-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachments' names are "tcmime.xxxx.xxxx.xxxx.bin" #277
Comments
I used "using BodyBuild" and "cast a MailMessage to a MimeMessage" |
The mail client you are using to read the message does not support rfc2231 encoding. Most likely it expects the filename parameter to be encoded using the rfc2047 encoding (which was never legal to use for encoding parameter values... but sigh, some mail software just sucks). There are 2 ways of controlling the encoding method used for parameter values. The first way is to set the encoding method on each individual Parameter: var attachment = bodyBuilder.Attachments.Add (.....);
foreach (var param in attachment.ContentDisposition.Parameters)
param.EncodingMethod = ParameterEncodingMethod.Rfc2047;
foreach (var param in attachment.ContentType.Parameters)
param.EncodingMethod = ParameterEncodingMethod.Rfc2047; The second way is to set the default parameter encoding method on the FormatOptions used for writing out the message and/or MIME part(s): var options = FormatOptions.Default.Clone ();
options.ParameterEncodingMethod = ParameterEncodingMethod.Rfc2047;
message.WriteTo (options, stream); |
I have seen the similar question--"Why do attachments with unicode filenames appear as "ATT0####.dat" in Outlook?" in http://www.mimekit.net/docs/html/FrequentlyAskedQuestions.htm#UntitledAttachments. I just don't know how to use the first way when I use BodyBuilder to add attachments to form a MineMessage, but now, I have tried the first way and get it. |
In a word, thank you for your great work! |
Yes, I think your code will work. |
If the attachment of a email has a file name which contains Chinese or non-ASCII characters and have a long length, no matter what the QQ mail is, sender or receiver, the mail's attachment in QQ mail's sent or in box shows as "tcmime.xxxx.xxxx.xxxx.bin", but other mail servers perform normal. You can see something about this in https://support.microsoft.com/en-us/kb/2402064
The text was updated successfully, but these errors were encountered: