Is there a fluent email library for c#?

4.8k Views Asked by At

I've been writing a bunch of email code lately and it occurred to me that it'd be pretty cool if there was a library that allowed you to fluently create an email in c#.

I had a quick look around but couldn't find anything so was wondering if anyone knew if there was a fluent email library that already existed for c#?

4

There are 4 best solutions below

0
On BEST ANSWER

I ended up finding this on GitHub which does what I want pretty nicely

https://github.com/dkarzon/FluentEmail

Also has the added bonus of allowing templates which can be used like so:

var email = Email
            .From("[email protected]")
            .To("[email protected]", "bob")
            .Subject("hows it going bob")
            .UsingTemplate(@"C:\Emailer\TransactionTemplate.htm")
            .Replace("<%CurrentDate%>", DateTime.Now.ToShortDateString())
            .Replace("<%FullName%>", fullName)
            .Replace("<%SaleDate%>", saleDate)
0
On

You can check out my Mail.dll email component:

Mail.Html(@"Html with an image: <img src=""cid:lena="""" />")
  .AddVisual(@"c:\lena.jpeg").SetContentId("lena")
  .AddAttachment(@"c:\tmp.doc").SetFileName("document.doc")
  .To("[email protected]")
  .From("[email protected]")
  .Subject("Subject")
  .SignWith(new X509Certificate2("SignCertificate.pfx", ""))
  .EncryptWith(new X509Certificate2("EncryptCertificate.pfx", ""))
  .EncryptWith(new X509Certificate2("BobsCertificate.pfx", ""))
  .UsingNewSmtp()
  .Server("smtp.example.com")
  .Send();

It's not free however and fluent interface is just syntactic sugar.

0
On

My Class :D http://www.mediafire.com/download/m7oua8gf4ject8m/Mail.cs

to use :

using Mailling;

    MailController m = new MailController("username", "password");

    private void Form1_Load(object sender, EventArgs e)
    {
        //Gett Mails
        List<Mail> mails = m.GetAllMails();
        foreach (Mail item in mails)
        {
            MessageBox.Show("From : "+item.From+"\n"+"Title: "+item.Title+"\n"+"Summary : "+item.Summary);
        }

        //SendMail
        m.SendMail("username", "password", "title", "summary");

    }
0
On

You can also check out this one. Fully featured and easy to use. Offers a fantastic way to build up templated emails.

http://www.avantprime.com/products/view-product/8/fluent-mail