4

I have a project that utilizes the javax.mail.internet.MimeMessage and other related classes that does mime parsing for emails that we receive. This needs to be ported to .NET.

What .Net 3rd party or built in library can I use to replace the Java classes that I'm using?

EDIT: Anything change in the last 9 months since I asked this question?

Ashish Ratan
  • 2,838
  • 1
  • 24
  • 50
Guy
  • 65,082
  • 97
  • 254
  • 325

7 Answers7

11

I've recently released MimeKit which is far more robust than any of the other open source .NET MIME parser libraries out there and it's orders of magnitude faster as well due to the fact that it is an actual stream parser and not a recursive descent string parser (which also has the added benefit of it using a LOT less memory).

It has full support for S/MIME v3.2 (including compression, which none of the other libraries that claim "full" support actually support) and OpenPGP.

For SMTP, POP3, and IMAP you can use my MailKit library which supports a bunch of SASL authentication mechanisms including XOAUTH2 (used by Google). The SMTP client supports PIPELINING which can improve performance of sending mail and the IMAP client supports a growing number of extensions that allow clients to optimize their bandwidth as well.

jstedfast
  • 35,744
  • 5
  • 97
  • 110
7

I've not used javax.mail.internet.MimeMessage, so I can't say how any of this compares, but .NET 2.0 and beyond does have a System.Net.Mime namespace which might have something useful for you.

Otherwise, I used Chilkat MIME .NET a long time ago and was happy with it.

Ryan Farley
  • 11,315
  • 4
  • 46
  • 43
6

SharpMimeTools, which is free and open source.

http://anmar.eu.org/projects/sharpmimetools/

It's what I use in my application, BugTracker.NET and it has been very dependable.

Corey Trager
  • 22,649
  • 18
  • 83
  • 121
2

I am in need of such a library, too. Looking for a mime processing library. I need to convert messages and attachments to PDF.
Here are some of the libraries I have found so far. Open Source Libraries:

Commercial Libraries:

  • Mime4Net
  • Rebex
  • Chilkat
  • Aspose - the most expensive option that I see.

(would have added more links, but my account level prevents me from doing so)

I am still sorting through these, and have not tried one yet. Probably gonna start with SharpMime since it's open source. Mime4Net has some examples on their site. From what I see, none of these offer the the conversion to PDF that I am needing, but there are other libraries I am looking at to fulfill that task.

Marty
  • 321
  • 3
  • 5
  • For the record, I ended up using AspNetMime, which uses an xml license file and does not hit a server to verify the license. They have a developer license which I am using, and it just works without hassle. My app has been in use over a year now and is working well. – Marty Aug 21 '11 at 02:34
2

I have used both, and concur with Ryan that the System.Net.Mime and sibling namespaces provide very similar functionality. If anything, I think you'll find that the .Net APIs are cleaner and easier to work with.

jsight
  • 27,819
  • 25
  • 107
  • 140
1

You may try a S/MIME library included in our Rebex Secure Mail component.

Features include:

  • high level API (MailMessage - as seen in email client)
  • low level API (access to a MIME tree)
  • autocorrecting code for mangled messages and for messages produced by misbehaving email clients
  • ability to read TNEF (aka winmail.dat created by Outlook)
  • S/MIME: sign/encrypt/decrypt messages
  • supports both .NET and .NET CF

Check features, MailMessage tutorial and S/MIME tutorial. You can download it at www.rebex.net/secure-mail.net

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

Try using Mail.dll IMAP component, it's on the market for quite a while, and is well tested.

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

    imap.SelectInbox();
    List<long> uids = imap.SearchFlag(Flag.Unseen);

    foreach (long uid in uids)
    {
        byte[] eml = imap.GetMessageByUID(uid);
        IMail message = new MailBuilder()
            .CreateFromEml(eml);

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

Please note that Mail.dll is a commercial product that I've created.

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

Pawel Lesnikowski
  • 6,264
  • 4
  • 38
  • 42