Created
July 14, 2013 19:48
-
-
Save aheld/5995611 to your computer and use it in GitHub Desktop.
Connecting to Microsoft Exchange using Java to download email messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import microsoft.exchange.webservices.data.*; | |
import java.net.URI; | |
public class Main { | |
public static void main(String [] args) throws Exception { | |
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); | |
ExchangeCredentials credentials = new WebCredentials("[email protected]","PASSWORD"); | |
service.setCredentials(credentials); | |
service.setUrl(new URI("https://EXCHANGE_SERVER_API_DOMAIN/ews/exchange.asmx")); | |
ItemView view = new ItemView (10); | |
FindItemsResults 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()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
I am trying your example with below url
https://outlook.nousinfo.com/ews/Exchange.asmx
I am getting error "Error in Data source validation Exchange Server outlook.nousinfo.com".
Let me know if you have faced the same issue.