Question

Is there some way to have the Mail Merge capability in my application? Maybe a MS Word API?

Was it helpful?

Solution

Yeah, you use Word Automation:

http://support.microsoft.com/kb/301659

OTHER TIPS

I've implemented it using a third-party library for Microsoft Word: Aspose Words.

There are some mail merge built-in functions. You won't need an installed copy of Microsoft Word on the client or server.

You could write your own functionality, maybe generating XML from your data (XmlSerialization could be your friend here) and using an XSLT transform to generate the output format of choice (HTML if you like, or even the XML formats direct for Word). The office integration might be of help, but it might not give the most integrated feel to your application.

The decision hinges on who'll be creating the templates -- if you just want predesigned ones, then the choice is more open -- if you want your end users to be creating them, you might just want to create a friendly way of generating (say) CSV for Word (or their favorite Word processor) to import and do the mail merge with.

I would not recommend using MS Word to provide a mail merge capability unless your application is already tied in to the MS Word API. Using it for just that one reason will be a decision that you are likely to regret - just as I regretted having done it a few years back. While it is true that most people have MS Word, you will end up supporting Word, the mail-merge interface, and your application while only really having control over your application. Even if the interface works perfectly on your computers (as it worked on ours) you are likely to find many, many people for whom your interface doesn't work at all. Remember, even a 3% failure rate may translate to thousands of calls if your application is popular!

If at all possible, roll your own mail merge using a third-party library/control for the word processing.

Good luck!

This one does not support (yet) doc or docx but it supports RTF. On the other hand, it's free :) and I'm actively working on enhace it more and more. Take a look, may be useful in your case. ntemplates.codeplex.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top