国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

JavaMail快速入門-6

2019-11-18 16:20:37
字體:
來源:轉載
供稿:網友

  receive()方法從main()方法中調用,它依次打開你的POP3信箱檢查消息,每次都調用PRintMessage()。代碼如下:

/**

* "receive" method to fetch messages and process them.

*/

public static void receive(String popServer, String popUser

, String popPassWord)

{

 Store store=null;

 Folder folder=null;

 try

 {

  // -- Get hold of the default session --

  Properties props = System.getProperties();

  Session session = Session.getDefaultInstance(props, null);

  // -- Get hold of a POP3 message store, and connect to it --

  store = session.getStore("pop3");

  store.connect(popServer, popUser, popPassword);

  // -- Try to get hold of the default folder --

  folder = store.getDefaultFolder();

  if (folder == null) throw new Exception("No default folder");

   // -- ...and its INBOX --

   folder = folder.getFolder("INBOX");

   if (folder == null) throw new Exception("No POP3 INBOX");

    // -- Open the folder for read only --

    folder.open(Folder.READ_ONLY);

    // -- Get the message wrappers and process them --

    Message[] msgs = folder.getMessages();

    for (int msgNum = 0; msgNum < msgs.length; msgNum++)

    {

     printMessage(msgs[msgNum]);

    }

  }

  catch (Exception ex)

  {

   ex.printStackTrace();

  }

  finally

  {

   // -- Close down nicely --

   try

   {

    if (folder!=null) folder.close(false);

    if (store!=null) store.close();

   }

  catch (Exception ex2) {ex2.printStackTrace();}

 }

}

(出處:http://m.survivalescaperooms.com)



上一篇:JavaRMI-IIOP入門

下一篇:JavaMail快速入門-7

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 禄丰县| 界首市| 大关县| 大新县| 永顺县| 迁西县| 湖南省| 蕉岭县| 安国市| 乌兰察布市| 阿勒泰市| 申扎县| 姚安县| 信阳市| 乐平市| 洪湖市| 奈曼旗| 青浦区| 正宁县| 营山县| 三穗县| 务川| 怀化市| 岳阳县| 宁都县| 平塘县| 阳原县| 七台河市| 汝南县| 锦屏县| 松桃| 山阴县| 丽水市| 宜都市| 金华市| 柳林县| 红原县| 乌兰浩特市| 颍上县| 湖北省| 北海市|