Products Downloads Purchase Support Company
Home : Products : IMAP4 Features

IMAP4 Features

Although many people are not familiar with IMAP4, it has many advantages over POP3.  IMAP4 provides many features that are essential for critical business systems.  ActiveUp.MailSystem is most likely the best IMAP4 component available on the market. Its object-oriented architecture, powerful features, and user-friendly programming model will save significant development time.

  • Ability to add messages to remote mailboxes
  • Ability to set message flags, such as "important" or "replied"
  • Remote folder management (list/create/delete/rename)
  • Folder hierarchies (nested folders)
  • Ability to determine message structure without having to download the entire message
  • Server-based search and retrieval to minimize data transfer
  • Etc...

One of the most interesting features is the fact that e-mails are stored on the server (like Microsoft Exchange Server) so you can check them from any machine, including webmail clients. This allows a single mailbox to be accessible to several people. At ActiveUp, the support e-mail is checked simultaneously by all the support team members using IMAP4.

IMAP4 can be thought of as a remote file server, whereas POP3 would be considered a "store-and-forward" service.

Another reason that ActiveUp.MailSystem is probably the best IMAP4 component on the market is that  its Object Oriented architecture, powerful features and incredibility easy to use programming model actually saves you considerable development time.

Official specifications and standards about IMAP4rev1 can be found in the following documents:

Manage Mailboxes (list, create, rename, delete, move, empty, etc.)

One of the most interesting features of IMAP4 is its capability to manage multiple mailboxes. ActiveUp.MailSystem provides an extensive set of simple methods to administer multiple mailbox accounts.

Below is a code example which lists the available mailboxes:

ShowShow C# code

// We create Imap client
Imap4Client imap = new Imap4Client();

// We connect to the imap4 server
imap.Connect("mail.example.com");

// Login to mail box
imap.Login("
user1@example.com", "username");

//Display all mailbox names on the account.
foreach (Mailbox mailbox in imap.Mailboxes)
{
    Console.WriteLine("Mailbox : {0}", mailbox.Name);
}

It is very easy to create, rename, delete, move, empty, or modify mailbox accounts. Below is a code example to create a new mailbox:

ShowShow C# code

// We create Imap client
Imap4Client imap = new Imap4Client();

// We connect to the imap4 server
imap.Connect("mail.example.com");

// Login to mail box
imap.Login("
user1@example.com", "username");

// We create a mailbox called "Project A"
imap.CreateMailbox("Project A");

// We rename it "Project B"
imap.RenameMailbox("Project A", "Project B");

// We remove all messages contained in mailbox "Project B"
Mailbox mailbox = imap.SelectMailbox("Project B");
mailbox.Empty(false);

// We delete the mailbox "Project B" from the account
imap.DeleteMailbox("Project A Backup");

Manage Messages (retrieve, copy, delete, append, etc.)

Because IMAP4 e-mail is server based, ActiveUp.MailSystem allows you to retrieve messages, or to copy, delete, or append to them.

This code demonstrates how to retrieve the first message in a specific mailbox:

ShowShow C# code

// We create Imap client
Imap4Client imap = new Imap4Client();

// We connect to the imap4 server
imap.Connect("mail.example.com");

// Login to mail box
imap.Login("
user1@example.com", "username");

// We get the inbox we will work with
Mailbox inbox = imap.SelectMailbox("inbox");
Mailbox archives = imap.SelectMailbox("archives");
               
// We can simply retrieve a message
Message message = inbox.Fetch.MessageObject(1);

// We can copy it to another mailbox in the account
inbox.CopyMessage(1, "archives");

// The delete it
inbox.DeleteMessage(inbox.MessageCount, "archives");

// We prefer to move it
inbox.MoveMessage(1, "archives");

// We can also append a message
archives.Append(message);

Manage Flags

Since IMAP4 is server based, you also have the ability to manage "flags" using ActiveUp.MailSystem functions.  A message can be flagged as "read", "replied", “follow-up”, etc.

ShowShow C# code

// We create Imap client
Imap4Client imap = new Imap4Client();

// We connect to the imap4 server
imap.Connect("mail.example.com");

// Login to mail box
imap.Login("
user1@example.com", "username");

// We select the inbox mailbox
Mailbox inbox = imap.SelectMailbox("inbox");

// We can set multiple flags to a same message
FlagCollection flags = new FlagCollection();
flags.Add("Answered");

// Set the specified flags for the message number 1
inbox.SetFlags(1);

Extended Search Features

A complete list of keywords that can be used to construct a query can be found in RFC2060, under the SEARCH COMMAND topic. This example will search the mailbox for messages that have been sent by "Mike Johns" since the 2nd of May 1999.

ShowShow C# code

// We create Imap client
Imap4Client imap = new Imap4Client();

// We connect to the imap4 server
imap.Connect("mail.example.com");

// Login to mail box
imap.Login("
user1@example.com", "username");

// We select the inbox mailbox
Mailbox inbox = imap.SelectMailbox("inbox");

// We get the message indexes matching the search criteria.
int[] indexes = inbox.Search("SEARCH SENT SINCE 2-May-1999 FROM \"Mike Johns\"");

// We get the message objects matching the search criteria.
MessageCollection messages = inbox.SearchParse("SEARCH SENT SINCE 2-May-1999 FROM \"Mike Johns\"");

New message arrival notification support (IDLE command)

Being notified in realtime of new messages arrivals using the new IMAP4 IDLE command will enpower your applications. While this is an IMAP4 feature, it is possible to use it in combination of POP3. Get notifications using IMAP4 and download emails using POP3.

ShowShow C# code

protected static Imap4Client imap4 = null;

public void IdleTest()
{
    // Initialize the IMAP4 client
    imap4 = new Imap4Client();

    // Attach the event handler
    imap4.NewMessageReceived += new NewMessageReceivedEventHandler(NewMessageReceived);

    // Connect
    Console.WriteLine("Connection...");
    imap4.Connect("mail.example.com");

    // Authenticate
    Console.WriteLine("Login...");
    imap4.Login("user01", "password01");

    // Select the main mailbox
    Console.WriteLine("Select 'inbox'...");
    imap4.SelectMailbox("inbox");

    // Start monitoring
    Console.WriteLine("Start idle...");
    imap4.StartIdle();
}

static void NewMessageReceived(object source, NewMessageReceivedEventArgs e)
{
    Console.WriteLine("New message received :" + e.MessageCount);

    // If you want to stop monitoring, use the StopIdle method
    // imap4.StopIdle();

}

Copyright © 2000-2007 Active Up - All Rights Reserved - Privacy Policy