using System;
using System.Data;
using System.Data.Odbc;
using Dimac.JMail;
namespace JMailTest
{
class MainClass
{
[STAThread]
static void Main( string[] args )
{
MailMerge mm = new MailMerge();
mm.Template.From = "me@mydomain.com";
mm.Template.To.Add( "<%# EmailAddress %>", "<%# Name %>" );
mm.Template.Subject = "Hello <%# Name %>";
mm.Template.BodyText = "Hello there <%# Name %>. This is your e-mail address: <%# EmailAddress %>!";
mm.OutputDirectory = "C:\\MailServer\\Pickup";
using( OdbcConnection connection = new OdbcConnection( "DSN=MyDSN" ) )
using( OdbcCommand command = new OdbcCommand( "SELECT EmailAddress, Name FROM Contacts", connection ) )
{
connection.Open();
using( IDataReader reader = command.ExecuteReader() )
{
mm.DataSource = reader;
MailMergeResult result = mm.DataBind( false );
Console.WriteLine( "Success: {0}, Failure: {1}", result.SuccessCount, result.FailureCount );
}
}
}
}
}