Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

New Post: Processing message after Folder.Search method executed

$
0
0
Hi. Thanks for your library, we are considering to use it for large project which will connect to lot of IMAP servers.

I found one issue, which I was able to fix locally by changing source codes of your library.

What we need:

We need to call Folder.Search method with bool makeProcess set to false;
And then later process each message returned by calling message.Process() method

But that doesnt work, and I think it is because after Folder.Search is done - Client returns to previous selected folder.

So what I did
  1. I added new field to Message class
internal Folder Folder; 
  1. In Folder.Search method - i added code to initialize Folder field of Message instance
foreach (var current in messageCollection)
            {
                current.Client = Client;
                __current.Folder = this;__
                if (makeProcess)
                {
                    current.Process();
                }
            }
  1. Then in Message.Process method I wrapped entire code into try catch; then in beginning I added this code
if (Client.SelectedFolder != Folder.FolderPath)
                {
                    returnToFolder = Client.SelectedFolder;
                    Client.SelectFolder(Folder.FolderPath);
                }
and in finally part of try catch I added code to return to original folder
if (!string.IsNullOrEmpty(returnToFolder))
                {
                    Client.SelectFolder(returnToFolder);
                }
returnToFolder is variable defined before try catch in Process method.

Please review this and if you think this is correct way to resolve issue, I guess you can include these changes into your library?

Thanks.

Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>