易截截图软件、单文件、免安装、纯绿色、仅160KB

Java Mail无法解析带分号的收件人列表的问题

Java Mail无法解析带分号的收件人列表的问题
      今天同事碰到一个问题,使用JAVA MAIL收取邮件时,如果收件人是个列表,且收件人列表是以分号进行分割的,则JAVA MAIL就会出现异常,不能正常解析,抽空看了一眼,自己写了个简单demo,很简单,例如:
  @Test
public void testReceiveMail() {

try {
String host = "pop3.163.com";
Properties pops = new Properties();
pops.put("mail.pop3.host", host);
pops.put("mail.pop.auth", "true");
Session session = Session.getDefaultInstance(pops, null);
Store store = session.getStore("pop3");
//连接邮件服务器
store.connect(host, "chb_go", "3870359346");
//收取收件箱
Folder inbox = store.getDefaultFolder().getFolder("INBOX");
//只读足够了
inbox.open(Folder.READ_ONLY);
//得到所有邮件列表
Message[] msg = inbox.getMessages();
FetchProfile profile = new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
inbox.fetch(msg, profile);
for (int i = 0; i < msg.length; i++) {
System.out.println("===============================================");
System.out.println("主题:"+msg[i].getSubject());
InternetAddress[] toAddress = (InternetAddress[]) msg[i].getRecipients(Message.RecipientType.TO);
for(InternetAddress adress:toAddress){
System.out.println(adress.getAddress());
}
}
//关闭打开的


相关文档:

Java, .Net发展方向和前景


Java, .Net发展方向和前景
JAVA语言发明已有10年历史,在IBM、SUN等公司的推动下已经比较稳定与成熟,获得了大规模企业的普遍应用。时至今日,J2EE已经发展成为一个覆盖面广,效率高,易用性强的技术平台,吸引了400万开发者,在网络技术遍及全球的的今天,更有17.5亿台设备使用JAVA技术.同时, Mustang版本的J2EE正在紧锣 ......

Java数组的复制(对象数组)

先看看下面的代码,大家猜猜输出是什么
package com.captain.test;
public class ArrayTest {
public static void main(String[] args){
//新建一个对象(OneNum)数组(赋值为5、3、4)
OneNum[] ac = {new OneNum(5),new OneNum(3),new OneNum(4)};
//新建一个与ac同长度的对象(OneNum)数组
OneNum[] n ......

Lesson1 Foundations of java and oo programming

Today , i take the first lesson of java ,let me sum up the details:
firstly,about jdk and jre.jdk stands for java development kit,while jre represent java Runtime Environment. jdk is the key of Java. And,jvm(java virtual machine) is the key of jre.
then ,about the platform independence of java.Dur ......

使用 Java Debug Interface(JDI)调试多线程应用程序

本文对 Java Debug Interface(JDI)及其使用进行了介绍,并通过实现一个多线程分析器的示例应用,演示了如何利用 JDI 开发自己的多线程调试程序。该示例分析器在独立于目标程序的前提下,以单个线程流为单位,帮助追踪记录多线程的执行过程信息。
多线程环境下的程序调试是让开发者头痛的问题。在 IDE 中通过添加断点的方 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号