The following samples are written as console applications. However the code can easily be ported to a Windows Form application or an ASP.NET Application. For a more complete list of online examples, and downloadable code samples, visit www.aspNetIMAP.com  Please note, for these examples you will need to change the Server and other Email addresses to reflect your situation.

Here is a list of the following examples:

General Examples

The following is a list of general IMAP examples.

Opening a MailFolder
The following example opens the "Inbox" folder, and writes out some basic information.

Downloading a Message
The following example opens the "Inbox" folder, and downloads the first message.

Downloading a Message's Headers
The following example opens the "Inbox" folder, and downloads the first message's headers.

Enabling Logging
The following example demonstrates creating a log file, and an in-memory log.

Load values from the Configuration File
The following example demonstrates dynamically loading values from the <appSettings> section of a configuration file, and setting various properties on the IMAP4 object.

Checking a message for Spam
The following example demonstrates using the BlackListChecker and DNSbl techniques to see if a message has been flagged as spam.

Using aspNetIMAP over SSL
The following example demonstrates how to modify your code for SSL support.

Working With MailFolders

The following list of examples deal with aspNetIMAP's MailFolders.

A Folder List
The following example lists out the folders of an IMAP mailbox.

Create a Folder
The following example demonstrates creating a MailFolder on the IMAP server.

Rename a folder
The following example renames a folder.

Delete a Folder
The following example deletes a folder.

Folder list to DataGrid
The following example demonstrates binding a list of folders to a DataGrid.

Folder list to XML
The following example demonstrates outputting a list of folders to XML.

Search a Folder
The following example demonstrates searching the FROM address for a part of an address.

Search a Folder II
The following example demonstrates searching the FROM address for an entire address.

Message Count
The following example demonstrates how to retrieve the message count for a given MailFolder.

New Messages
The following example demonstrates how to retrieve the headers for only new messages.

Working with Messages

The following list of examples deal with manipulating messages found on an IMAP server.

Messages Explained
The following is an explanation of how Messages work in the IMAP protocol.

Download a Message as a MimeMessage
The following example demonstrates how to download a textual message as a MimeMessage object.

Copy a Message
The following example demonstrates how to copy a message to a different MailFolder.

Delete a Message
The following example demonstrates how to mark a message for deletion and then purge it from the IMAP server.

Move a Message
The following example demonstrates how to move a message from one folder to a different folder.

Mark a Message set as Read
The following example demonstrates how to mark a message set as being read.

Mark a Message as Answered
The following example marks a message as being answered.

Mark a Message as Flagged
The following example marks a message as flagged.

Retrieve a BodySection
The following example demonstrates how to retrieve a specific section of a message.

Retrieve a listing of Attachments
The following example demonstrates how to retrieve a list of attachments found in a message.

Download an Attachment by Index
The following example demonstrates how to download an attachment, by it's index found in the message.

Download an Attachment by Name
The following example demonstrates how to download an attachment, by the attachment's name.