在Exchange Web服务的帮助下访问outlook时,我收到了身份验证错误401。
以下是我连接到Outlook的代码:
public static void usingEWS(){
try {
System.out.println("***********************************************");
//System.setProperty("javax.net.ssl.trustStore", "C:\\Users\\vermad\\Downloads\\Softz\\jssecacerts");
System.setProperty("javax.net.ssl.trustStore","C:\\Users\\username\\Downloads\\Softz\\jssecacerts");
ExchangeCredentials credentials = new WebCredentials("xyz@domain.com","password","domain.com");
service.setCredentials(credentials);
service.setUrl(new URI("https://vabcxdp/EWS/Exchange.asmx"));
ItemView view = new ItemView (5);
//System.out.println(service.getCredentials());
//System.out.println("2");
//getting error here
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Inbox, view);
for(Item item : findResults.getItems()){
item.load(new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent));
System.out.println("id==========" + item.getId());
System.out.println("sub==========" + item.getSubject());
System.out.println("sub==========" + item.getMimeContent());
}
} catch (Exception mex) {
mex.printStackTrace();
}
}
答案 0 :(得分:0)
我可以使用系统用户名代替用户名示例来解决问题:amukati而不是用户名:amukati@xyz.com