We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Support for adding image in signature of mail message (C# .NET)

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)
return result ?? message_.Clone();


I have observed your requirements and like to share that we need to investigate further about adding image as signature in mail message. An issue with ID EMAILNET-39279 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@mudassir.fayyaz, thanks for that. Hopefully it will lead to a useful update.

As an alternative to using the template engine, I found some sample code from the Aspose web site which adds images to a html body through LinkedResource objects. (https://docs.aspose.com/display/emailnet/Creating+and+setting+contents+of+Emails).

The code wraps an image in a LinkedResource as per the extract below.

LinkedResource barcode = new LinkedResource(dataDir + “1.jpg”, MediaTypeNames.Image.Jpeg)
ContentId = “barcode”

However in our Aspose version (DotNet, 19.1) the LinkedResource class does not have a ContentId property.
Do you have example of embedding images in a mail message in v19.1?


We need to investigate the requirement further on our end and will get back to you with feedback on this as soon as possible.


I have verified the part of above sample code on concerned example code. There has been no issue with LinkedResource class. I suggest you to please visit this Github example link for complete example. You can download the working example Aspose.Email project to verify the working of examples as well.

thanks. I was just missing a using directive.


Its good to know things are fine on your end.

We have found issues with attaching signatures via linked resources.
So far only Office 365 mail servers send the email as expected.
We have tested with 3 smpt servers (Office 365, mailgun, netregistry) and several mail clients.

  • Office 365 seems to re assemble the mail message before sending.
  • netregistry seems to send it as text even though the message BodyType is set to HTML.
  • mailgun seems to remove the embedded signature image

Frankly, we are not sure what is going on.

I can send you a small VS solution which contains some of the test cases if that helps. It contains smtp credentials so I would prefer it to be kept private. How can I deliver it to you?


I have observed the information shared by you and request you to please share the requested information in order to reproduce the issue on our end.

Hi @mudassir.fayyaz,
I have attached a test project which displays the behaviour.
There are tests for

  • office 365 (_365)
  • mail gun (_mg)
  • netregistry (_mit)

You will need to provide office 365 credentials s I don’t have access to a test account atm.

Aspose Tests.zip (3.3 MB)


Thank you for sharing the information. I have added an issue with ID EMAILNET-39423 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi, I never saw any response to this issue.
has it been resolved?
If so what do we need to do to obtain the fix?


We are sorry for your inconvenience that you were unable to receive the notification. Can you please share the latest Aspose.Email for .NET 19.8 on your end.