Java---使用EWS读取exchange邮件
2020-12-13 05:02
标签:http list logging rom htm mpi 时间 地址 red 第一步: 第二步: 第三步: ##:Java---关于如何使用EWS 写个ExchangeMailUtil 详见 : Java---使用EWS读取exchange邮件 标签:http list logging rom htm mpi 时间 地址 red 原文地址:https://www.cnblogs.com/itczybk/p/11128469.html下载EWS API相关包:
从如下路径下载EWS API包:http://code.msdn.microsoft.com/Exchange-EWS-Java-API-12-1a5a1143
导入依赖:
- Apache Commons HttpClient 3.1 (commons-httpclient-3.1.jar)
- Apache Commons Codec 1.4 (commons-codec-1.4.jar)
- Apache Commons Logging 1.1.1 (commons-codec-1.4.jar)
- JCIFS 1.3.15 (jcifs-1.3.15.jar)
(或者导入pom.xml):
ReadEmail代码示例:
public class ReadExchangeMail{
public static void main(String[] args){
//使用exchange服务工具类创建服务
//ExchangeMailUtil exchangeMailUtil = new ExchangeMailUtil(mailServer, user, password, readUrlPrefix);
//ExchangeService service = exchangeMailUtil.getExchangeService();
//创建exchange服务 ExchangeVersion.Exchange2007_SP1 (服务版本号)
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
ExchangeCredentials credentials = new WebCredentials("用户名", "密码", "域");
service.setCredentials(credentials);
service.setUrl(new URI("https://"+"邮箱服务器地址"+"/EWS/Exchange.asmx"));
// Bind to the Inbox.
Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
System.out.println(inbox.getDisplayName());
ItemView view = new ItemView(10);
// 查询
FindItemsResults
https://www.cnblogs.com/itczybk/articles/11011744.html