0 votes
by (360 points)
edited

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
by (147k points)
edited

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

by (147k points)
edited

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
by (147k points)
edited
 
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);
...