userTokenField example?

Can the userTokenField parameter be used to alter the body of a mail message in a Merge operation? I’d like to insert a unique url in the body of the message for each recipeint. Any examples or thoughts on how to accomplish this? Thanks.

Hello,

Thanks for considering Aspose.Network

If you wanna insert a unique url in the body of the message for each recipient, please try our Mail Merge operation. Mail Merge can create a batch of similar mails:

Demo:

//Create mail message template
Aspose.Network.Mail.MailMessage msg;
msg = new Aspose.Network.Mail.MailMessage();
msg.From = new Aspose.Network.Mail.MailAddress(“sender@aspose.com”);
msg.Subject = “Hi, ##name##!”;
Aspose.Network.Mail.TextPlainBody plainBody = new Aspose.Network.Mail.TextPlainBody();
plainBody.Content = “Hello, ##name##! \n please visit ##url## \n thank you!.”;
msg.Body = plainBody;

//Defined the DataTable
System.Data.DataTable dt;
dt = new System.Data.DataTable();
dt.Columns.Add(“AddrTo”, typeof(string));
dt.Columns.Add(“name”, typeof(string));
dt.Columns.Add(“url”, typeof(string));

dt.Rows.Add(new object[]{
“john@domain.com”,
“John”,
“www.aspose.com”} );
dt.Rows.Add(new object[]{
“july@domain.com”,
“July”,
“www.aspose.com”});
dt.Rows.Add(new object[]{
“alec@domain.com”,
“Alec”,
http://yourdomain.com”});
//SmtpClient perform the mail merge and bulk send
Aspose.Network.Mail.SmtpClient mailClient;
mailClient = new Aspose.Network.Mail.SmtpClient(“smtp.yourdomain.com”);
mailClient.Merge(msg, new Aspose.Network.Mail.DataTableMerger( dt, “AddrTo”, string.Empty, string.Empty, string.Empty ));
try
{
mailClient.BulkSend();
}
catch(Exception ex)
{
System.Diagnostics.Trace.WriteLine( ex.Message );
}

Please visit [http://www.aspose.com/Wiki/default.aspx/Aspose.Network/MailMerge.html](https://forum.aspose.com/Wiki/default.aspx/Aspose.Network/MailMerge.html) for more info about Mail Merge

Thanks again

Ah. I wasn’t aware of the ##field## notation. Assumed it only worked with email address. Thanks.