We are using the TemplateEngine to generate a mail message from a mail template. Current code (excerpt below) only does text substitutions.
We want to be able to also add a signature to the generated email.
You have a sample (https://github.com/aspose-email/Aspose.Email-for-.NET/blob/master/Examples/CSharp/SMTP/MailMerge.cs) which appears to add a signature by registering a method in the line:
engine.RegisterRoutine(“GetSignature”, GetSignature);
Are we able to insert an image (rather than text) using this method? If so please provide some sample code.
What other ‘things’ can we use the RegisterRotine() method for?
Also are we able to insert images via the engine.Merge() method?
Thanks for your assistance.
Excerpt from our code
///
/// creates a new message by applying mail merge operation to message_
/// - if no merge data, returns a clone of message_
///
///
///
private MailMessage ExpandMacros(MailMessage message_, Pair<string, string>[] macro_list_, string salutation_)
{
var fixed_cc_for_merge = false;
if (message_.CC.Count == 0)
{
message_.CC = message_.From;
fixed_cc_for_merge = true;
}
MailMessage result = null;
if (message_ != null && message_.AlternateViews.Count != 0)
{
var data = GetMacroSubRow(macro_list_, salutation_);
if (data.ItemArray.Length != 0)
{
var engine = new TemplateEngine(message_);
result = engine.Merge(data);
}
}
if (fixed_cc_for_merge && result != null)
{
result.CC.Clear();
}
return result ?? message_.Clone();
}