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

exchange装配访问总结

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

 

Exchange安装访问总结

这几天对Exchange的了解进行了一个简单的总结。做了一个简单的文档,主要记录的是EXchange的安装方法。里边有访问Exchange的会议和任务的代码。使用的是JEC。

 

具体代码如下 

 

package org.yangzc.jec.demo;

import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import jec.ExchangeConnectorInterface;
import jec.ExchangeGeneralException;
import jec.dto.ExchangeEventDTO;
import jec.dto.ExchangeTaskDTO;

public class ExchangeDemo {

	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		ExchangeConnectorInterface connector = 
			ExchangeUtils.getExchangeConnector();
		try {
			connector.setEmailFolderName(URLEncoder.encode("收件箱"));
			ArrayList<?> list = connector.getEmails();
			System.out.println("########################## Email 有"+list.size()+"条");
			
			connector.setTasksFolderName(URLEncoder.encode("任务"));
			ArrayList<?> tasklst = connector.getTasks();
			System.out.println("########################## Task 有"+tasklst.size()+"条");
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			for(int i=0; i<tasklst.size(); i++){
				ExchangeTaskDTO task= (ExchangeTaskDTO) tasklst.get(i);
				System.out.println("主题:" + task.getSubject());
				System.out.println("截止日期:开始于:" + sdf.format(task.getStartDate()) +"  " +
						"截止于:" + sdf.format(task.getDueDate()));
				System.out.println("状态:" + task.getStatus());
				System.out.println("优先级:" + task.getPriority());
				System.out.println("完成百分率:" + task.getPercentComplete());
				System.out.println("内容:" + task.getDescription());
			}
			
			connector.setCalendarFolderName(URLEncoder.encode("日历"));
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		    Date startDate = dateFormat.parse("2011-06-21 6:00:00");
		    Date endDate = dateFormat.parse("2011-12-22 19:00:00");
		    ArrayList<?> eventlst = connector.getEvents(startDate, endDate, 100);
			System.out.println("########################## Event 有"+eventlst.size()+"条");
		    for(int i=0; i< eventlst.size(); i++){
		    	ExchangeEventDTO event = (ExchangeEventDTO) eventlst.get(i);
		    	System.out.println("事件内容:"+event.getDescription());
		    	System.out.println("主题: " + event.getSubject());
			    System.out.println("位置: " + event.getLocation());
			    System.out.println("开始时间:" + sdf.format(event.getStartDate()));
			    System.out.println("结束时间: " + sdf.format(event.getEndDate()));
      			System.out.println("内容:" + event.getDescription());

		    }
		} catch (ExchangeGeneralException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
}



package org.yangzc.jec.demo;

import jec.ExchangeConnectorFactory;
import jec.ExchangeConnectorInterface;

public class ExchangeUtils {

	public static ExchangeConnectorInterface getExchangeConnector(){
		String _exchangeHost = "192.168.1.24";
    	String _applicationUserAccountName = "yangzc";
    	String _applicationUserPassword = "1";
    	String _prefix  = "Exchange";
    	boolean _useSSL = true;
    	String _mailboxName = "yangzc";
    	
    	ExchangeConnectorFactory factory = 
	    	new ExchangeConnectorFactory("E:/D/eclipse-javascript/workspace/jex/lib");
        factory.setPrivkeystoreFullPath("E:/D/eclipse-javascript/workspace/jex/lib/privkeystore");
        ExchangeConnectorInterface connector = null;
        connector = factory.createExchangeConnector(_exchangeHost,
                _applicationUserAccountName,
                _applicationUserPassword,
                _prefix, 
                _useSSL, 
                _mailboxName);

       return connector;
	}
}

 

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

 

随机推荐程序问答结果

 

 

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