当前位置:编程学习 > JSP >>

改写后的使用javamail pop3收信的javabean

/*
*Author:tyfun
*DateTime:2003.01.10
*Package:com.westarsoft.mail
*/
package com.westarsoft.mail;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import java.io.*;
public class GetMail {
    public static String receive(String popServer, String popUser, String popPassword) {
        String mailContent = "";
        Store store = null;
        Folder folder = null;
        try {
            Properties props = System.getProperties();
            Session session = Session.getDefaultInstance(props, null);
            store = session.getStore("pop3");
            store.connect(popServer, popUser, popPassword);
            folder = store.getDefaultFolder();
            if(folder == null) throw new Exception("No default folder");
            folder = folder.getFolder("INBOX");
            if(folder == null) throw new Exception("No POP3 INBOX");
            folder.open(Folder.READ_ONLY);
            Message[] msgs = folder.getMessages();
            for(int msgNum = 0; msgNum < msgs.length; msgNum++) {
补充:Jsp教程,邮件
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,