Getting a System.InvalidOperationException in Rebex.Net.Imap.DLL

0 votes
asked Oct 19, 2011 by TestCSSL (360 points)
edited Oct 19, 2011

I'm trying to fetch the IMAP headers and the body (message & attachments) seperately.
Fetching the headers is no problem, but when I try to fetch the body Rebex.Net.Imap.DLL throws a System.InvalidOperationException.

 ConnectAndLogin();
 var message = _imap.GetMailMessage(uniqueId);

I have no idea if I did something wrong, or that it is a bug/error in the library...

Applies to: Rebex Secure Mail
commented Oct 19, 2011 by Lukas Pokorny (116,670 points)
edited Oct 19, 2011

What does the exception message say? It's impossible to tell what is going on without this piece of information.

commented Oct 19, 2011 by Lukas Pokorny (116,670 points)
edited Oct 19, 2011

An even better option would be to create a communication log using Imap object's LogWriter property (as described at http://www.rebex.net/kb/logging.aspx). Please create the log and either add it to your post or mail it to support@rebex.net for analysis. Thanks!

1 Answer

+1 vote
answered Oct 19, 2011 by Lukas Pokorny (116,670 points)
edited Oct 19, 2011
 
Best answer

According to the log you sent us, the exception message is "No folder is selected". This means that you have to select a folder first before calling a method such as GetMailMessage that works on the current folder. For example, if you need to access messages in your Inbox folder, call SelectFolder("Inbox") first:

ConnectAndLogin();
_imap.SelectFolder("Inbox")
var message = _imap.GetMailMessage(uniqueId);
...