首页 新闻 搜索 专区 学院

MailMessage 带附件发邮件-Firefox中文显示正常,网页打开邮件中文名附件乱码

0
悬赏园豆:20 [待解决问题]

  

  //attachment = new Attachment(path, MediaTypeNames.Application.Octet);
                        //attachment.Name = System.IO.Path.GetFileName(path); 
                        //attachment.NameEncoding = Encoding.GetEncoding("gb2312");//
                        //attachment.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
                        //attachment.ContentDisposition.Inline = true; 
                        //attachment.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Inline;

                        string extName = Path.GetExtension(fileName);
                        if (extName == ".zip" || extName == ".rar")
                        {
                            attachment = new System.Net.Mail.Attachment(new FileStream(path, FileMode.Open, FileAccess.Read), fileName, MediaTypeNames.Application.Zip);
                        }
                        else
                        {
                            attachment = new System.Net.Mail.Attachment(new FileStream(path, FileMode.Open, FileAccess.Read), fileName, MediaTypeNames.Application.Octet);
                        }
                        //string cid = attachment.ContentId;//关键性的地方,这里得到一个id数值 
                        //ContentDisposition disposition = attachment.ContentDisposition;
                        //disposition.CreationDate = System.IO.File.GetCreationTime(path);
                        //disposition.ModificationDate = System.IO.File.GetLastWriteTime(path);
                        //disposition.ReadDate = System.IO.File.GetLastAccessTime(path);
                        mailMessage.Attachments.Add(attachment);

 

 

在网页中打开邮件,附件中文名就出现乱码

Firefox正常

 

见图;

 

 

 

 

 

谢谢!!

PEPE YU的主页 PEPE YU | 初学一级 | 园豆:29
提问于:2015-07-03 19:51
< >
分享
所有回答(1)
0

估计是附件的正文的编码方式跟附件名的编码方式不一致吧,检查一下,把各个部分的编码方式统一起来。

liqipeng | 园豆:1160 (小虾三级) | 2015-07-04 20:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册