javamail里面的中文问题(接收邮件,发送的时候都已经解决) 我的mail: [email protected] 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 附件的中文名问题是javamail的bug,他忘了处理编码了你自己分析那个字符串,然后赋值就好了String xxx = yourcode(fileName);//bodyPart2.setFileName(fileDataSource.getName());bodyPart2.setFileName(xxx);这样应该可以了 String fileName = "e:/temp/中文.htm"; //这里比较一下就知道了,如果设置为fileName2,文件名就对了,但是却无法找到文件了,所以这样不行 String fileName2 = new String(fileName.getBytes("GBK"),"ISO-8859-1"); System.out.println(fileName); System.out.println(fileName2); //fileName = fileName2; Properties aProperties = System.getProperties(); aProperties.put("mail.transport.protocol","smtp"); aProperties.put("mail.smtp.host","smtp.xxx.com"); Session session = Session.getInstance(aProperties,null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("[email protected]")); message.setRecipient(Message.RecipientType.TO,new InternetAddress("[email protected]")); message.setSubject("Hello,中文"); BodyPart bodyPart1 = new MimeBodyPart(); bodyPart1.setText("Hello,中文"); BodyPart bodyPart2 = new MimeBodyPart(); FileDataSource fileDataSource = new FileDataSource(fileName); bodyPart2.setDataHandler(new DataHandler(fileDataSource)); //bodyPart2.setFileName(fileDataSource.getName()); String fn2 = getFileName (fileName); //这个自己去实现,应该很简单吧 bodyPart2.setFileName(fn2); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(bodyPart1); multipart.addBodyPart(bodyPart2); message.setContent(multipart); message.saveChanges(); message.writeTo(System.out); Transport.send(message); getDeclaredMethods返回父类Method? socket小问题 求教一下~ java实现对 百度百科中 文字 的获取~ 鼠标与键盘事件写代码 线程问题迷茫了~~是高手就来挑战 问一个关于gc的基本问题 在weblogic一个域下的两个应用,怎么传递数据? 如何输出字符串,将其中的'\n'输出为\n 谢谢各位了! 关于生成可执行文件的问题,请进来讨论(200分) 用jdbc读取数据的时候,有这个警告:但是不影响读取数据 关于JAVA开发手机软件的问题 怎样将一个整数转化为字符串?
//bodyPart2.setFileName(fileDataSource.getName());
bodyPart2.setFileName(xxx);这样应该可以了
String fileName = "e:/temp/中文.htm";
//这里比较一下就知道了,如果设置为fileName2,文件名就对了,但是却无法找到文件了,所以这样不行
String fileName2 = new String(fileName.getBytes("GBK"),"ISO-8859-1");
System.out.println(fileName);
System.out.println(fileName2);
//fileName = fileName2; Properties aProperties = System.getProperties();
aProperties.put("mail.transport.protocol","smtp");
aProperties.put("mail.smtp.host","smtp.xxx.com"); Session session = Session.getInstance(aProperties,null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("[email protected]"));
message.setRecipient(Message.RecipientType.TO,new InternetAddress("[email protected]")); message.setSubject("Hello,中文"); BodyPart bodyPart1 = new MimeBodyPart(); bodyPart1.setText("Hello,中文"); BodyPart bodyPart2 = new MimeBodyPart(); FileDataSource fileDataSource = new FileDataSource(fileName);
bodyPart2.setDataHandler(new DataHandler(fileDataSource));
//bodyPart2.setFileName(fileDataSource.getName());
String fn2 = getFileName (fileName); //这个自己去实现,应该很简单吧
bodyPart2.setFileName(fn2); Multipart multipart = new MimeMultipart();
multipart.addBodyPart(bodyPart1);
multipart.addBodyPart(bodyPart2); message.setContent(multipart); message.saveChanges();
message.writeTo(System.out); Transport.send(message);