Skip to content
Norbert Bietsch edited this page Aug 28, 2016 · 20 revisions

Welcome to the MailMergeLib wiki

Getting started

Send a single mail message

var variables = new Dictionary<string, object>() { { "Email", "[email protected]" }, {"Name", "John Specimen"} };

// create a new message with plain text and HTML body parts
// Placeholders are the variable names in curly braces
var mmm = new MailMergeMessage("Personal message for {Name}", "This is pure text for {Name}",
			"<html><head><title>No title</title></head><body>This is HTML text for {Name}</body></html>");

mmm.MailMergeAddresses.Add(new MailMergeAddress(MailAddressType.From, "[email protected]"));
mmm.MailMergeAddresses.Add(new MailMergeAddress(MailAddressType.To, "{Name}", "{Email}"));

var mms = new MailMergeSender();

mms.MaxNumOfSmtpClients = 1;  // enough for a single email
mms.Config.SmtpClientConfig[0].MessageOutput = MessageOutput.SmtpServer;
mms.Config.SmtpClientConfig[0].ClientDomain = "mail.sample.com";
mms.Config.SmtpClientConfig[0].SmtpHost = "smtp.mailprovider.net";
mms.Config.SmtpClientConfig[0].SmtpPort = 587;
mms.Config.SmtpClientConfig[0].NetworkCredential = new Credential("username", "password");
mms.Config.SmtpClientConfig[0].MaxFailures = 3;

mms.Send(mmm, variables);
Clone this wiki locally