Search code examples
c#emailfluent-interface

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 fluent email library that already existed for c#?


Solution

  • 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)