Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Dear Coders,

I've just started using your ImapX library to retrieve and read mails from gmail.
Now, everything is working fine and it's a great library.

However, when i'm trying to mark a mail read using the Message.Process() option, it returns the IndexOutOfRangeException.

C#
private void Start()
        {
            int amountRead = 0;
            failedMessages.Clear();

            foreach(string origin Properties.Settings.Default.MailOrigins)
            {
                IMailOriginAdapter adapter = MailOriginFactory.CreateMailOriginContainer(origin);

                foreach (ImapX.Message message in adapter.Messages())
                {
                    if (SendWebRequest(url))
                    {
                        message.Process();
                        amountRead++;

                        Dispatcher.BeginInvoke(new MethodInvoker(delegate
                        {
                            this.btnStart.Content = "Read [" + amountRead + "/" + GmailUser.Instance.Messages.Count + "]";
                        }));
                    }
                    else
                    {
                        failedMessages.Add(message);
                    }
                }

                System.Windows.MessageBox.Show(adapter.GmailFromEmail() + " reading completed.");
            }
        }


Or in a more simple example:

C#
private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            foreach (Message message in adapter.Messages())
            {
                message.Process();
                worker.ReportProgress(mailsRead);
                mailsRead++;
            }
        }



Hopefully someone's capable of helping me with this problem which i've had now for over then a month..

Thanks in advance.

Yours Sincerely,
Larssy1
Posted
Updated 16-Feb-13 5:22am
v2
Comments
Sergey Alexandrovich Kryukov 15-Feb-13 14:11pm    
It does not "return" exception. Exceptions are not returned, they work "over" the usual stack call-return mechanism.
In what line?
Did you use the debugger to see how the range and actual values match? Such problems usually easy and are best resolved with the debugger.
—SA
larssy1 16-Feb-13 11:27am    
Hi Sergey,

The line where the error occurs is on the message.Process() line.
When trying to press F11 (step into), it returns a call stack error on line 144 in Message.cs of the ImapX Library.

Everything about the message object in my code, seems to be fine.

Any Ideas?

Gz,
Larssy1
Sergey Alexandrovich Kryukov 16-Feb-13 19:13pm    
I don't see your line numbers. You can simply comment the lines in question and reference by those comments. What's "call stack error"? How about exact exception full type name and message? see also internal exception.
—SA
larssy1 19-Feb-13 18:02pm    
Please see the following screenshot for the Exception object.
http://i80.photobucket.com/albums/j185/larssy1/screen.png

This error message is while executing the following code:

try { message.Process(); }
catch (Exception ex)
{
String s = ex.Message;
}
Sergey Alexandrovich Kryukov 19-Feb-13 18:04pm    
"Error message"? Exception? What line?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900