为什么80%的码农都做不了架构师?>>>
文章图片
第一步,下载EWS JAVA 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)
也可以通过maven下载,EWSJavaAPI的jar包需要先手动安装,POM.xml
4.0.0
com.yotoo
ReadEmail
war
1.0-SNAPSHOT
ReadEmail
http://maven.apache.org
UTF-8
1.6
1.4.7
1.7.3
3.8.1
javax.mail
mail
${mail.version}
compile
org.jsoup
jsoup
${jsoup.version}
commons-httpclient
commons-httpclient
3.1
commons-codec
commons-codec
1.4
jcifs
jcifs
1.3.17
commons-logging
commons-logging
1.1.1
microsoft.exchange.webservices
EWSJavaAPI
1.2
junit
junit
${junit.version}
test
ReadEmail
第三步,示例代码 ReadMailViaEWS.java
public class ReadMailViaEWS { public static void main(String[] args) throws Exception {
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- findResults = service.findItems(inbox.getId(), view);
for (Item item : findResults.getItems()) {
EmailMessage message = EmailMessage.bind(service, item.getId());
System.out.println(message.getSender());
System.out.println("Sub -->" + item.getSubject());
} }}
【通过 EWS JAVA API读取exchange邮件】转载于:https://my.oschina.net/yotoo/blog/288428
推荐阅读
- Java|Java基础——数组
- 人工智能|干货!人体姿态估计与运动预测
- java简介|Java是什么(Java能用来干什么?)
- Java|规范的打印日志
- Linux|109 个实用 shell 脚本
- 程序员|【高级Java架构师系统学习】毕业一年萌新的Java大厂面经,最新整理
- Spring注解驱动第十讲--@Autowired使用
- SqlServer|sql server的UPDLOCK、HOLDLOCK试验
- jvm|【JVM】JVM08(java内存模型解析[JMM])
- 技术|为参加2021年蓝桥杯Java软件开发大学B组细心整理常见基础知识、搜索和常用算法解析例题(持续更新...)