SmtpClient 附件中文檔名亂碼問題
發表於 : 週二 9月 13, 2011 11:32 am
代碼: 選擇全部
string fileName = @"C:\小堃모발 이식 비용堃一杯を求めて ラーメンは進化し続ける雲端時代來臨,心動不如馬上行動,搶先體驗 VIdegree 愛顧客服務!.exe";
sub = string.Format("=?UTF-8?B?{0}?=", Convert.ToBase64String(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(fileName)));
Attachment file = new Attachment(f, "", "application/octet-stream; charset=Big5; name=\"" + sub + "\"");
^^^^ 一定要丟空改用丟第三個參數
ContentDisposition disposition = file.ContentDisposition;
// Suggest a file name for the attachment.
disposition.FileName = sub;
//file.Name = sub; <<<< 沒甚麼鳥用
file.TransferEncoding = TransferEncoding.Base64;
mailMessage.Attachments.Add(file);