0 votes
by (200 points)

I am trying to download emails from my outlook account. In my outlook account, there is 20 Inbox folder. When I try to download emails from the folder it takes a lot of times.

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (72.7k points)

Please note that downloading whole message can take a lot of time. It also downloads attachments which can be large.

I don't know what you are trying to achieve, but consider to:

  1. List messages using EwsItemFields.Fast or EwsItemFields.Default message field value.
  2. You can even use paged output.
  3. Retrieve more information about particular message using GetMessageInfo method sequentially when needed.
  4. Download whole message only when it is really necessary.

If you are still thinking that our implementation is notably slower than other .NET managed implementation, please let us know.

by (200 points)
Actually, I want to download all the latest emails. Every minute I call my download method to check for the latest message.

My main problem is my inbox contains 22 folders. I have to check each folder that the folder contains the new message or not.

// My Code Block
 foreach (var folder in folders.Where(a => a.Name.ToLower().Contains("inbox")))
                    {
                        imap.SelectFolder(folder.Name);//  It Takes 3-5 second to enter into the folder.
                       var data = imap.Search(ImapSearchParameter.Arrived(lastSyncDate,currentDate)).Reverse().ToList();

                        if (data != null && data.Count > 0)
                        {
                                // My Download Process
                         }
                   }


To enter the folder it takes 3-5 second. That means it takes 60-80 second to traverse the folder only.

Is there any smart way to find the latest message?
by (72.7k points)
Unfortunately, we cannot do much to speed up `SelectFolder` method. Can you please send us communication log, so we can see possible issue. It can be done like this:

imap.LogWriter = new Rebex.FileLogWriter("your.log.path", Rebex.LogLevel.Debug);

If you don't need to modify mails in your folders, you can try read-only select like this:

imap.SelectFolder("Inbox", true);

Unfortunately, client can search for mails in selected folder only. There is no way to search for mails in more folders.
...