MailMerge.Execute object[] parameter

All the examples of MailMerge.Execute(string[], object[]) show you passing plain strings, which is quite limited in its usefulness.

I previously passed Editor.Document objects successfully, but since the editor is discontinued we’ ve replaced it with our own Rich Text Editor. I’ m able to read the RTF into an Aspose.Document just fine, but when the Document is passed to MailMerge.Execute it just displays the type name in my document.

So, what object types does MailMerge.Execute(string[], object[]) support that will preserve formatting?

Thanks,
Heath

Hi

Thanks for your request. I think, in your case, you can try using technique like described here:
You can find InsertDocuemnt method here:
https://forum.aspose.com/t/99414
https://docs.aspose.com/words/net/insert-and-append-documents/
Hope this helps. Please let me know if you need more assistance, I will be glad to help you.
Best regards.

Alexey,

I’ve seen your suggested example and it’s flawed. The InsertDocument() method inserts the text at the wrong place in the document, not inline where the merge field is.

Using this as a very simple example:
"<<Person>> went to the park."

Would output:
“went to the park.
Heath”

I pretty sure it 's this line: CompositeNode dstStory = insertAfterNode.ParentNode;

I don’t want it after the parent, I want it exactly where the mergefield was.

(Note: I 've tested a dozen different ways and think this is the result I got with this method.)

I’ve been able to piece something together but it really shouldn’t take so much code (roughly 85 LOC) to import the paragraphs/tables of one document into another document at a specific location.

But back to my original question: What Object types are supported in the MailMerge.Execute(string[], object[]) method? If it’s anything other than string is it simply doing a ToString() on the objects?

Please let me know if I’m missing something.

Thanks.

Hi
Thanks for your inquiry. You can try using modified InsertDocumentAtMergField method, which is provided in this thread:
Hope this helps.
Best regards,

That was exactly what I needed! Much cleaner than my version. Thanks.

Although I am still interested in how object[] is supported in MailMerge.Execute(string[], object[])…

Is there any value in passing anything other than strings?

Hi
Thanks for your inquiry. You can pass any object as a value. Object will be converted to string upon inserting. So if you pass for example int you will see number if you pass DateTime you will see date.
Best regards,