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

New Post: How to display a message?

$
0
0
Hi jallvar,

first of all, feel free to contact me in Russian through mail: p13a92@gmail.com

A small remark on your code

I recommend setting client.Behavior.AutoPopulateFolderMessages to true before connecting. This will keep your code clean, doing all major configuration of the client in one place.

Searching for messages

The general information on searching for messages can be found in the documentation. If you like to perform a search by the subject of the message, or a specific sender, use the following approach:
// Search all messages containing "@oplata.info" in the FROM field
var messages = client.Folders.Inbox.Search("FROM \"@oplata.info\"");

// Search all messages containing "Test" in subject
var messages = client.Folders.Inbox.Search("SUBJECT \"Test\"");
A full list of available criterias can be found in the specification.
If you like to perform a query with non-ascii characters (e.g subject in russian), use this thread for reference.
In case you are planning to use the library with the servers of mail.ru, please consider that their server implementation is not complete and doesn't allow the use of various search criterias.

Displaying messages

For displaying a message in a Windows Forms project you can use a WebBrowser control. The sample application you can find in the downloads section does the same. This is the approximate code:
// Getting the available body (html is priority, text used if no html body available)
string body = message.Body.HasHtml ? message.Body.Html : message.Body.Text;

// Open a new document in WebBrowser
webBrowser1.Document.OpenNew(true);

// Writing the message body to the document
webBrowser1.Document.Write(message.Body.HasHtml ? body : body.Replace(Environment.NewLine, "<br />"));
                
Best regards,

Pavel

Viewing all articles
Browse latest Browse all 1952

Trending Articles



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