my code is as follows:
ContentType ct = new ContentType(); ct.MediaType = MediaTypeNames.Application.Octet; ct.Name = "这是一个很长的中文文件名希望能用它在附件名中.Doc"; Attachment attach = new Attachment(stream, ct);
but the received attribute does not match the correct Chinese file name, and I found ct.Name becames "=? utf-8? B? 6L + Z5piv5LiA5Liq5b6I6ZW / 55qE5Lit5paH5paH5Lu25ZCN5biM5pyb? = \ r \ n =? utf-8? Z56Z55Z65Z65Z65Z65Z6? 6o6? 5? 6o6? 5? 6? VS2010 debugger.
Plz tip, how can I use Chinese characters in the attachment file name?
Can you try:
Attachment att = new Attachment(@"c:\path to file\somename.txt", System.Net.Mime.MediaTypeNames.Application.Octet); //this itself should work. att.Name = "-.doc"; // non-english filename //if the above line doesn't make it work, try this. att.Name = System.Web.HttpUtility.UrlEncode(att.Name, System.Text.Encoding.UTF8);
, . MIME- ASCII, (. RFC 2047).
, UTF-8 base-64 - , =?utf8?B?. .
=?utf8?B?
: oops, , , . , , , , , , .
Finally, I found a workstation, according to RFC 2047, the delimiter can be CRLF or SPACE between "ecoded-word", and C # uses CRLF as the delimiter, but the NOTES / Gmail client cannot interpret it even after I replaced CRLF on SPACE, it works well in NOTE / Gmail.
Thanks Rup, your RCF2047 link will help me!
Source: https://habr.com/ru/post/1779375/More articles:Обработка откатов в выводе SQL Server - sql-serverHow to analyze heap dump using jhat - javaFormsAuthentication.SignOut () using javascript - javascriptSQL: setting condition on the result of an aggregate function - phpDynamically add a stylized tag to an ASP.Net web page - htmlIs it possible to update a commit in Mercurial? - version-controlSelect all columns except those that have only null values - sql.net naming convention: is there a semantic difference between length and graph? - .netPartitioning a query by JPA 2 criteria - javaHow to deserialize a soap reaction using multiref in .net? - xml-deserializationAll Articles