欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

java 联接 exchange服务

更新时间: 2014-01-05 03:03:29 责任编辑: Author_N1

 

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();
		}
.这个网站上的事例需要许可证,时间长了可能过期,你要上网问这个邮箱jonathan.sanders@netcompss.com
索取key文件,老外叫Jonathan Sanders,人挺好的

上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 03:03:29
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/17806/
本文WWW.DOC100.NET DOC100.NET版权所有。