EMail

  1. 添加中文名附件(使用库:email,如果没有源码可参考GitHub上)

        MimeBodyPart.setFileName(filename);

        直接使用有可能中文乱码可以使用如下的方法

    • MimeBodyPart.setFileName(MimeUtility.encodeWord(fileName));

                使用这个可以实现中文的显示(客户端和服务器端都可以)

                可以查看RFC2047文件了解encodeWord详情。下面部分原文信息……


                Generally, an "encoded-word" is a sequence of printable ASCII

                characters that begins with "=?", ends with "?=", and has two "?"s in

                between. It specifies a character set and an encoding method, and

                also includes the original text encoded as graphic ASCII characters,

                according to the rules for that encoding method.


                A mail composer that implements this specification will provide a

                means of inputting non-ASCII text in header fields, but will

                translate these fields (or appropriate portions of these fields) into

                encoded-words before inserting them into the message header.


    • MimeBodyPart.setFileName(new String(fileName.getBytes(), "ISO-8859-1"));

                使用这个可以,客户端可以显示,服务端显示异常。(“复制”到服务器端显示为“澶嶅埗”)。



转载于:https://my.oschina.net/u/557213/blog/384294

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值