切换到宽版
  • 13658阅读
  • 2回复

[分享]JAVA 连接访问 Exchange 服务 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2013-08-22
JAVA 连接 Exchange服务
联合经济委员会提供了一个纯Java API来访问Microsoft Exchange Server。有了它,您可以访问和处理电子邮件,日历,联系人,并在Exchange服务器任务。它支持2种执照- 1)非利润,学术机构,以及个人,和2)商业。欲了解更多信息请参阅:http://javaexchangeconnector.googlepages.com这是google快照,里面有不错的事例。简单的连接
String _exchangeHost = "192.168.0.29";
                String _applicationUserAccountName = "beijing";
                String _applicationUserPassword = "123456";
                String _prefix  = "Exchange";
                boolean _useSSL = false;
                String _mailboxName = "beijing";
            ExchangeConnectorFactory factory = new ExchangeConnectorFactory("D:/web/www/eclipse-workspace/java_exchange/WEB-INF/lib");
//        ExchangeConnectorInterface connector = null;
        factory.setPrivkeystoreFullPath("D:/web/www/eclipse-workspace/java_exchange/WEB-INF/lib/privkeystore");
//            ExchangeConnectorFactory factory = new ExchangeConnectorFactory();
        ExchangeConnectorInterface connector = null;
        connector = factory.createExchangeConnector(_exchangeHost,
                _applicationUserAccountName,
                _applicationUserPassword,
                _prefix, _useSSL, _mailboxName);
System.out.println("connector.getDraftsFolderName():"+connector.getDraftsFolderName());
        //connector.getEmailFolderName();
        System.out.println("connector.getEmailFolderName():"+connector.getEmailFolderName());
        try {
//                connector.getFolders("http://192.168.0.29/exchange/beijing/%E5%8F%91%E4%BB%B6%E7%AE%B1/");//http://192.168.0.29/exchange/liuwg/%E6%94%B6%E4%BB%B6%E7%AE%B1/
                        //草稿 %E8%8D%89%E7%A8%BF
                //收件箱 %E6%94%B6%E4%BB%B6%E7%AE%B1
                //发件箱 %E5%8F%91%E4%BB%B6%E7%AE%B1
                //已发送邮件 %E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6

                connector.setEmailFolderName("%E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6");
                ArrayList list = connector.getEmails();
                        System.out.println("########################## Email 有"+list.size()+"条");

                        for(int i=0; i<list.size(); i++){

                                ExchangeEmailDTO email = (ExchangeEmailDTO) list.get(i);
                    System.out.println("email1.getUniqueIdForUrl(): " +
                                       email.getUniqueIdForUrl());
                    System.out.println("email1.getSubject(): " +
                                       email.getSubject());
//                    System.out.println("email1.getBody(): " +
//                                       email.getBody());
                    System.out.println("email1.getDateReceived(): " +
                                       email.getDateReceived());
                    System.out.println("email1.getTo(): " +
                                       email.getTo());
                    System.out.println("email1.getFrom(): " +
                                       email.getFrom());
                    System.out.println("email1.isRead: " +
                                       email.isRead());
                    System.out.println("email1.getCc: " +
                                       email.getCc());
                    System.out.println("email1.getBcc: " +
                                       email.getBcc());
                    System.out.println("----------------------------------------------------------------");
                        }
                } catch (ExchangeGeneralException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
分享到
只看该作者 1楼  发表于: 2013-12-26
大哥,
ExchangeConnectorFactory factory = new ExchangeConnectorFactory("D:/web/www/eclipse-workspace/java_exchange/WEB-INF/lib");

这一段里面的参数是什么意思啊?
只看该作者 2楼  发表于: 2013-12-26
你用的是JEC的jar 包,那license不是每隔6天就需要申请一个?
快速回复
限60 字节
 
上一个 下一个