Bidehalaxmi
Bidehalaxmi

Reputation: 11

Reading emails from office365 Outlook account using Java

We have a requirement to read emails from an Office365 account and show them in our Java EE application. We have done it using JavaMail and its working as expected; but the issue is with performance. Its taking around 30 secs to 3 minutes to read the emails depending on the size of mail or attachments. Is there any way we can improve this performance ? Following are few more details of the approach we have taken.

  1. We are retrieving the mails using IMAPStore
  2. The emails that we need to read are not inside inbox. Its in a different folder outside of it. This folder again has sub-folders which holds the filtered emails based on the subject.
  3. While reading the mails we read from a particular folder then show them in our application in the same hierarchy as they are present in the mail server.

We thought of different alternative approaches like reading from a PST file or storing the emails into our database by a background process then reading from the DB but none of them really worked out. Is there any other way of doing this. We found there is a Office365 SDK for android, can we make use of that ?

Upvotes: 1

Views: 3112

Answers (1)

Bill Shannon
Bill Shannon

Reputation: 29971

First, it's not "JEE", it's "Java EE".

You haven't really provided any details on exactly what you're doing that takes 30 seconds to 3 minutes. Is it reading 1 message? Is it reading 1000 messages?

And what exactly do you mean by "reading" the message? Just displaying the header information, or displaying all the message content as well?

Does the time include the time to connect to the server and open the folder? Or just the time to access the message(s) after you've opened the folder?

Have you looked at the JavaMail debug output? If you use java.util.logging to get timestamped logging output, you might be able to tell which operation is taking the time.

Are you using the Folder.fetch method to prefetch the message data in bulk?

Why do you believe that it isn't just Office365 that's slow?

With more details we might be able to provide more hints for how to improve the performance of your program.

Upvotes: 1

Related Questions