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());
}
}
//关闭打开的
相关文档:
先看看下面的代码,大家猜猜输出是什么
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 ......
初探java内存机制_堆和栈
问题的引入:
问题一:
String str1 = "abc";
String str2 = "abc";
System.out.println(str1==str2); //true
问题二:
String str1 =new String ("abc");
String str2 =new String ("abc");
System.out.println(str1==str2); // false
问题三:
String s1 = "ja";
String s2 = "v ......
package tf;
public class TestPack {
public static void main(String [] args)
{
try
{
IAnimal cAnimal = new bird();
cAnimal.shout();
IAnimal animal =(IAnimal)java.lang.Class ......
JDK1.5中的线程池(java.util.concurrent.ThreadPoolExecut
6
推荐
在多线程大师Doug Lea的贡献下,在JDK1.5中加入了许多对并发特性的支持,例如:线程池。
一、简介
线程池类为 java.util.concurrent.ThreadPoolExecutor,常用构造方法为:
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize,
long keepA ......
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 ......