This project has moved. For the latest updates, please go here.

The following sample code shows you a simple example using fluent code to configure the Email Notification wrapper.

using System;
using System.Collections.Generic;

namespace EmailNotification
{
    public class Example1
    {
        public void Main()
        {
            var serverConfig = new ServerConfiguration();
            
            var emails = new List<MessageQueueEntity>
                             {
                                 new MessageQueueEntity
                                     {
                                         To = "test@test.com",
                                         From = "from@test.com",
                                         Body = "Test Email",
                                         BodyFormat = BodyFormat.PlainText,
                                         Created = DateTime.Now
                                     }
                             };


            var configuration = Master.Configure()
                .WithServerConfiguration(serverConfig)
                .IsEnabled(true)
                .WithEmails(emails);

            var result = Master.Execute(configuration);
        }
    }

    public class ServerConfiguration : IServerConfiguration
    {
        public string SmtpServer
        {
            get { return "Server Name"; }
        }

        public int SmtpServerConnectionLimit
        {
            get { return -1; }
        }

        public bool SmtpServerRequiredLogin
        {
            get { return false; }
        }

        public string SmtpServerUserName
        {
            get { return "User Name"; }
        }

        public string SmtpServerPassword
        {
            get { return "Password"; }
        }

        public bool IsSSLEnabled
        {
            get { return false; }
        }

        public int SmtpServerPort
        {
            get { return 25; }
        }

        public bool UseDefaultCredentials
        {
            get { return false; }
        }
    }
}

Last edited Apr 11, 2011 at 2:57 AM by mjourdan, version 2

Comments

No comments yet.