This project is read-only.

Body text

Aug 4, 2012 at 9:46 AM
Edited Aug 4, 2012 at 9:49 AM

I'm trying to get to grips with using ImapX - I am doing something wrong when getting messages though.

messagesCollection contains the right number of messages (2) however the decoded body returns an empty string, as does the subject:

I've tried with isHTML both true and false, with the same result.


Eventually I want to download the body of all emails from a particular sender with a particular subject.  Any pointers towards that would be great!


var client = new ImapClient("",993,true);
bool result = client.Connection();

result = client.LogIn("*****", "*****");

var folderCollection = client.GetFolders();

var messagesCollection = client.Folders["INBOX"].Messages;

var isHTML = true;
var messageBody = messagesCollection[0].GetDecodedBody(out isHTML);
var messageSubject = messagesCollection[0].Subject;
Aug 5, 2012 at 10:41 AM

Good day!

The messages are not downloaded completely by default, so your code needs a minor change:

var messageCollection = client.Folders["INBOX"].Search("ALL", true);

This should allow you to download all messages from the inbox.

To your question about downloading messages from a particular sender: Filtering the messages without downloading them completely is not possible yet, but we'll do out best to implement it in future versions.

We also plan to remove the GetDecodedBody method in future and give direct access to the decoded bodies through the HtmlBody and the TextBody fields. The goal is to make the usage of the library simple and intuitive.

Please watch our new releases and the updates of the documentation!