commonsmailjavaMail发送附件时,收到的附件文件名称和类型变成bin了

时间:2008-08-19 15:09:24   来源:论坛整理  作者:  编辑:chinaitzhe
Java code





Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/







        request.setCharacterEncoding("gbk");

        File file = doAttachment(request);



        MultiPartEmail email = new MultiPartEmail();

        email.setCharset("gbk");

        email.setHostName("smtp.sina.com");

        email.setAuthentication("tianlesoftware", "woshidmm");



        try {

            email.addTo(parameters.get("to"));

            email.setFrom(parameters.get("from"));

            email.setSubject(parameters.get("subject"));

            email.setMsg(parameters.get("content"));

            if (file != null) {

                EmailAttachment attachment = new EmailAttachment();

                

System.out.println("file  " file);

                attachment.setPath(file.getPath());

System.out.println("file.getPath()  "  file.getPath());                

                attachment.setDisposition(EmailAttachment.ATTACHMENT);

System.out.println("EmailAttachment.ATTACHMENT  "  EmailAttachment.ATTACHMENT);                    

                attachment.setName(file.getName());

System.out.println("file.getName()  "  file.getName());                    

                email.attach(attachment);                

            }

            email.send();





输出一切正常,但邮箱接收的中文附件就变成134.bin之类的拉。
怀疑是attachment.setName(file.getName());有问题,但输出是正确的文件。

各位解释下是什么原因呢?
关键字:附件,名称,类型,文件,

文章评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面