Free Support Forum - aspose.com

TemplateEngine token replace

I am using Aspose.Network (Ver: 3.8.0.0). I am using the TemplateEngine to "merge" a MailMessage and DataTable together. I works great !!!!. The replacement tokens in the subject line and body of the message are being replaced just fine. (Ex: Token: #Firstname# being replaced with Don).

My problem. I need to create a custom header with a value from the DataTable, but it doesn't appear the TemplateEngine does token replace for Headers.

I would like the TemplateEngine to do token replace in the headers.

Example Code:

MailMessage message = new MailMessage();

message.Headers.Add("EmailEventID","#EmailEventID#");

TemplateEngine engine = new TemplateEngine(message);

MailMessageCollection messages;

messages = engine.Instantiate(<<>>);

When I review the messages in the message collection, the Header EmailEventID has #EmailEventID# as it's value instead of the value 12345679 from the DataTable.

Suggestion for Aspose.....Please enable token replacements in the Header.

Hello,

It is a good idea. We will investigate about how to support it shortly. I will keep you posted.

Thanks,

Thanks. That's great to hear. I'm pretty much dead in the water without it unless there is another way to uniquely identify MailMessages using a user generated unique key. Basically, I read data from a database, then, once the email is sent, I need to update the database that it was send or failed and why. Using BulkSend, if an error occurred and the SmtpFailedBulkSendException is raised with the failed messages in the FailedSentMessages collection, there's no way to uniquely identify the messages with the database key so I can log the error.

Until the token replacement for headers has been deployed, do you have any suggestions?

Cheers.

Could you post part of your code here? Therefore, I can make sure that we are in the same picture of the scenario.

Thanks

Example Code:

MailMessage message = new MailMessage();

message.Headers.Add("EmailEventID","#EmailEventID#");

TemplateEngine engine = new TemplateEngine(message);

MailMessageCollection messages;

messages = engine.Instantiate(<<>>);

When I review the messages in the message collection, the Header EmailEventID has #EmailEventID# as it's value instead of the value 12345679 from the DataTable.

NOTE: #EmailEventID# is the token

Hello, dongertz

Thanks for the information.

I think we are clear enough. Our developer is working on your design change request now. The hotfix will be available before next week.

Best regards

Hello,

We have finished this feature. Please check it out,

http://www.aspose.com/products/Aspose.Network/Releases/3.8.0/Aspose.Network.v3.8.0.2.zip

Thanks

I have tested the new dll and it works great. Thanks for the quick turnaround.