Fluent.NET Mail

Last Update
18 June 2013
Regular License
$10
Extended License
$50
Sales
19

Fluent.NET Mail takes advantage of the built in .NET API and provides the ability to construct and send emails very easily. All the messy work is taken care of in the background and allows the simple focus of easily constructing emails using custom templates including dynamic substitution of data into your template, sending mail in various formats (text & HTML), choosing your means of transportation (SMTP, Network, Pickup), using security certificates, using SSL, sending attachments, sending mail asynchronously plus all the features provided by the .NET framework.

This is the single easiest and most comprehensive .NET emailing API available. Easy to use and powerful!

When would I use this?

Sending bulk emails for marketing campaigns Working with template driven emails Very simple, comprehensive and easy to use API Fully functional for secure emails, delivery & read notifications, attachments, alternate views, etc

What are the advantages?

Very high performance Simple to use Uses logical processor count for number of pipelines unless explicitly configured Documented API Support provided at support.avantprime.com

Constructs and sends emails using a Fluent paradigm Provides a complete API for sending emails with various configurations including with SSL, mail headers, attachments, alternate views, mail priority, encoding, delivery notification options, etc Send both text and html emails Building emails using text or html templates Complete integration with the standard .NET mail mechanisms & the web.config/app.config Delivery receipts Read receipts Secure emails Plus much moreā€¦

What do you get in the package?

.NET 2.0 Assemblies Debug files (PDB) XML comments (Intellisense) Usage documentation C# Source Code Visual Studio 2010 SP1 & 2012 Solution Documented API Console demo application

Technologies

This component is built using the .NET 2.0 Framework which means in can be used in all .NET applications that are using the 2.0 framework or newer. This includes .NET 2.0, 3.5, 4.0, & 4.5+.

You can immediately use this within your application and is very simple. Ask any questions or suggest features at support.avantprime.com!

How to use this component?

The example below shows how to send an HTML email using SSL with high priority.

new Mail() .To(new MailBox(emailAddress)) .From(new MailBox(emailAddress)) .Subject("Fluent API .NET") .Html("This is the body of the email") .WithSsl() .WithCertificate(new X509Certificate()) .Priority(MailPriority.High) .SmtpServer("[your smtp server]") .Send();

The example below shows how to send a templated HTML email with an alternate templated text view for those clients that cannot view html emails.

new Mail() .Html(new MessageTemplate() .FromText("This is my email with <b>{content}</b> text") .DataFrom(new { content = "html" }) .BetweenBraces()) .WithAlternateView(new MessageTemplate() .FromText("This is my email with [content] text") .DataFrom(new { content = "plain" }) .BetweenSquareBrackets()) .To(new MailBox(emailAddress)) .From(new MailBox(emailAddress)) .Subject("Fluent API .NET 2") .SmtpServer("[your smtp server]") .Send();

The example below shows how to send a templated HTML email with an image attachment. asynchronously and do some work when the email has been sent.

new Mail() .To(new MailBox(emailAddress)) .From(new MailBox(emailAddress)) .Subject("Fluent API .NET 1") .Html(new MessageTemplate() .FromText("This is the {token} of the email. Pic attached") .DataFrom(new { token = "body" }) .BetweenBraces()) .WithAttachment(new Attachment("DSC00831A.jpg", new ContentType("image/jpeg"))) .SmtpServer("[your smtp server]") .SendAsync(SmtpClient_OnCompleted);

// This method is called when message has been sent, cancelled or there is an error public static void SmtpClient_OnCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) { Console.WriteLine("Send canceled"); } if (e.Error != null) { Console.WriteLine("Error {0} occurred", e.Error); } else { Console.WriteLine("Message sent."); } }

The example shows how to send a templated text email while loading the template from a file.

new Mail() .To(new MailBox(emailAddress)) .From(new MailBox(emailAddress)) .Subject("Fluent API .NET 6") .Text(new MessageTemplate() .FromFile("templates/my-template.txt") .DataFrom(new { content = "html" }) .BetweenBraces()) .SmtpServer("[your smtp server]") .SendAsync(SmtpClient_OnCompleted);

The example compares the tranditional approach of sending email with the new fluent approach.

// Fluent API - Simple, easy with great performance and // behind the scenes memory management new Mail() .From(new MailBox(emailAddress, "NoReply")) .To(new MailBox(emailAddress, "Support")) .Subject("Mail sent " + DateTime.Now.ToLongTimeString()) .Port(587) .WithoutDefaultCredentials() .Credentials(emailAddress, "[password]") .DeliveryMethod(SmtpDeliveryMethod.Network) .Text("body") .SmtpServer("[your smtp server]") .Send();

var fromAddress = new MailAddress(emailAddress, "NoReply"); var toAddress = new MailAddress(emailAddress, "Support");

var smtp = new SmtpClient { Host = "[your smtp server]", Port = 587, EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = true, Credentials = new NetworkCredential(fromAddress, fromPassword) };

using (var message = new MailMessage(fromAddress, toAddress)) { message.Subject = "Mail sent " + DateTime.Now.ToLongTimeString(); message.Body = "body"; smtp.Send(message); }