Is there a fluent email library for c#?
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 flu开发者_运维百科ent email library that already existed for c#?
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("john@email.com")
.To("bob@email.com", "bob")
.Subject("hows it going bob")
.UsingTemplate(@"C:\Emailer\TransactionTemplate.htm")
.Replace("<%CurrentDate%>", DateTime.Now.ToShortDateString())
.Replace("<%FullName%>", fullName)
.Replace("<%SaleDate%>", saleDate)
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("to@mail.com")
.From("from@mail.com")
.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.
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");
}
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
精彩评论