Continuing the discussion from Aspose.Email compatability in with JDK12 (Java):
Hi Team,
I have an requirement to read email from exchange server with JDK8 (JAVA) source code so can you please help me JAVA 8 source code to connect & read email from MS exchange server.
Thanks,
Pankaj
@pankajastegic,
Thank you for your query. You can configure dependencies with Aspose.Email as below:
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-email</artifactId>
<version>21.3</version>
<classifier>jdk16</classifier>
</dependency>
You can connect to the exchange server as following:
final String mailboxUri = "https://outlook.office365.com/ews/exchange.asmx";
final String domain = "";
final String username = "username@onmicrosoft.com";
final String password = "password";
NetworkCredential credentials = new NetworkCredential(username, password, domain);
IEWSClient client = EWSClient.getEWSClient(mailboxUri, credentials);
More details: Connecting to Exchange Server
You can read the email from the exchange server as following:
String inboxUri = client.getMailboxInfo().getInboxUri();
ExchangeMessageInfoCollection messages = client.listMessages(inboxUri);
More details: Working with Exchange Mailbox and Messages
API Reference: IEWSClient interface
Thank you Andrey_Potapov!!! your quick reply helps me lots.