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

The following sample code shows you a simple example using a configuration file to use with the Email Notification service.

Configuration File

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="EmailNotificationSettings" type="EmailNotification.Config.EmailNotificationConfigurationSectionHandler, EmailNotification" allowLocation="false" allowDefinition="Everywhere"/>
  </configSections>
  <EmailNotificationSettings isEnabled="true">
    <ServerSettings smtpServer="smtp.gmail.com" isSSLEnabled="true" smtpServerConnectionLimit="4" smtpServerPassword="password" 
                    smtpServerUser="test@gmail.com" smtpServerRequiredLogin="true"/>
    <DefaultFrom emailAddress="store@gmail.com" displayName="Store"></DefaultFrom>
    <TestEmailAccounts isTestEmailAccountsBlocked="true">
      <add account="mailinator.com"></add>
    </TestEmailAccounts>
  </EmailNotificationSettings>
</configuration>

Configuring and calling Email Notification Wrapper

using System;
using System.Collections.Generic;

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

            var configuration = Master.UseAppConfig().WithEmails(emails);

            Master.Execute(configuration);
        }
    }
}

Last edited Apr 21, 2011 at 1:42 PM by mjourdan, version 5

Comments

No comments yet.