2

One year ago Mitchel Sellers had a related question...

I would like to access the Google IMAP for sending and receiving email messages within my custom application.

The point is that i would not like to use any third party controls.

Newer versions of the .Net Framework support IMAP? What options do i have?

Community
  • 1
  • 1
OrElse
  • 9,709
  • 39
  • 140
  • 253
  • 1
    and here http://stackoverflow.com/questions/670183/accessing-imap-in-c and here http://stackoverflow.com/questions/545724/using-c-net-librarires-to-check-for-imap-messages-from-gmail-servers but still the same answer –  Oct 05 '09 at 13:42
  • @Will There is also the world wide web becides the SO – OrElse Oct 05 '09 at 13:47

3 Answers3

1

There used to be the Indy components for Borland Delphi which have been ported to C# and .NET.

There is no native support for this, As far as I know.

Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
1

There is no .NET framework support for IMAP. You'll need to use some 3rd party component.

Try Mail.dll email component, it's very affordable and easy to use:

using(Imap imap = new Imap())
{
    imap.Connect("imapServer");
    imap.Login("user", "password");

    imap.SelectInbox();
    List<long> uids = imap.SearchFlag(Flag.Unseen);
    foreach (long uid in uids)
    {
        string eml = imap.GetMessageByUID(uid);
        IMail message = new MailBuilder()
            .CreateFromEml(eml);

        Console.WriteLine(message.Subject);
        Console.WriteLine(message.TextDataString);
    }
    imap.Close(true);
}

You can download it here: http://www.lesnikowski.com/mail/.

Pawel Lesnikowski
  • 6,264
  • 4
  • 38
  • 42
  • I have made the switch to Ubuntu for future development. Is there any way to get this library to work with C# Mono on Linux or to work with the Vala programming language? – jay_t55 Jul 13 '14 at 23:44
-2

There is no IMAP support in current versions of .NET and I have not heard about any plans to add such support to the framework. You have to try one of third party components.

You may check our Rebex Secure Mail.

Following code shows how to download messages from the Inbox folder:

// create client, connect and log in 
Imap client = new Imap();
client.Connect("imap.example.org");
client.Login("username", "password");

// select folder 
client.SelectFolder("Inbox");

// get message list 
ImapMessageCollection list = client.GetMessageList(ImapListFields.Fast);

if (list.Count == 0)
{
    Console.WriteLine("There are no messages in the mailbox.");
}
else 
{
    // download the first message 
    MailMessage message = client.GetMailMessage(list[0].SequenceNumber);
    ...
}

Trial can be downloaded from www.rebex.net/secure-mail.net/

You may also enjoy Rebex Q&A forum which runs on similar engine as this site.

Martin Vobr
  • 5,757
  • 2
  • 37
  • 43