Has anyone been able to get this library working using a WebApi Controller that accepts a dynamic object/payload and passes it on to MailMergeSender.Send? On my dto.Payload, I have tried accepting a dynamic, an ExpandoObject, an object, a Dictionary<string,string>, and additionally I have tried casting all of these to object and always produces the same error. The controller accepts the request just fine, and I can access and see the variables correctly when setting a breakpoint and using the immediate window.
It works just fine if I manually pass an object that I create in the code (ie: at compile time) such as:
new { ProjectId = "123", ProjectName = "hi" }
But with a dynamic object generated at runtime, none of the functionality seems to work. This may be a bug in SmartFormatter, since if I try to pass the same object to a basic Smart.Format call, it also does not work.
var message = new MailMergeMessage() { Config = settings.MessageConfig };
message.Subject = "Subject - Project ID: {ProjectId}";
message.HtmlText = "Body - Project Name: {ProjectName}";
_sender.Send(message, emailRequestDto.Payload);
VariableException: Variable(s) for placeholder(s) not found: {ProjectId}, {ProjectName}
I am building a micro service that accepts email requests using templates already sent to the service. The payload is completely dynamic and specific to each consumer and their template. Is it possible to use this library for this purpose?