0 people following this project (follow)

Project Description
LEMs4 (Lazarus' Extention Methods for .NET 4.0) is a library of extention methods for .NET 4 that enable you to write shorter code in less time.

LEMs4 is developed in c# and is a work in progress. I will continually add and improve extention methods.



Sending a HTML email w/o using LEMs:
using System;
public class SendSomeMail
{
   public static void Main()
   {
            var client = new SmtpClient("mailserver", 25);
            client.Credentials = new NetworkCredential("username", "password");
            client.EnableSsl = true;

            var message = new MailMessage("from@host.com","to@host.com","the subject", "<html>the body</html>");
            var attachment = new Attachment("filename")
            message.Attachments.Add(attachment);
            message.IsBodyHtml = true;

            client.Send(message);   
   }
}

Sending a HTML email with LEMs:
using Be.Lazarus.LEMS;
public class SendSomeMail
{
   public static void Main()
   {
    new SmtpClient()
        .initialize()
        .PrepareHtmlMail("hello world","recipient@host.com","sender@host.com")
        .AddAttachment("filename")
        .Send();
   }
}

Last edited Feb 8 at 7:09 AM by HansPolders, version 11