views:

234

answers:

4

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

+2  A: 

Yeah, you use Word Automation:

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

BobbyShaftoe
A: 

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.

Rowland Shaw
A: 

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!

Mark Brittingham
+2  A: 

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.

splattne