Is there a fluent email library for c#?
Asked Answered
M

4

9

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#?

Masonite answered 17/2, 2011 at 12:8 Comment(2)
what do you mean by fluent? is System.Net.Mail too difficult to use for you? Of course you can create your own class which wraps it and makes it easier and simpler to use it...Monreal
Think he wants something like: Send(message).To(recipient).And(recipient2).From(sender).Now();Gormless
M
6

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)
Masonite answered 18/2, 2011 at 2:16 Comment(0)
S
3

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.

Streptomycin answered 17/2, 2011 at 13:32 Comment(0)
O
1

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");

    }
Ordway answered 29/11, 2015 at 15:54 Comment(0)
S
-2

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

Source answered 2/7, 2011 at 9:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.