Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have to create a word document in a specific format and send it as attachment to some email addresses.

I have a preview screen for the report which on approval has to be send in email. This is an ASP.NET MVC 3 application.

I am left with a few options here.

  1. I am creating the preview using html. I can convert this html into doc and send it, which would be a straight solution. But capturing the Response object's output is being a tough job.

  2. I thought of using Mail merge functionality of MS word, where I'll be filling the placeholders of the doc template. But the problem is conceptually, it doesn't appear to be mail merge.

  3. I have found someone suggesting to use RTF format and replace the placeholders with database values.

Which is the right thing to do? What's the best solution here? Is there any other option than the three listed above?

share|improve this question
    
How are 2. and 3. different? –  TZHX Sep 11 '12 at 14:35
    
2 is the inbuilt Mail merge feature of MS Word. 3 is all manual, find and replace of place holders in RTF file. –  SaravananArumugam Sep 11 '12 at 14:52
add comment

2 Answers

up vote 2 down vote accepted

Dealing with MS Office is always requiring a lot of tweaks and trade-offs. Did you had a chance to look at Open XML SDK?

You may easily use Open Xml SDK. It's free, you don't need any Office libraries and there are many resources on the web. This one, for example.

share|improve this answer
add comment

I've had a lot of success using SyncFusion's DocIO library. I had a scenario similar to yours. I stored a Word Template in the database, used the DocIO library to generate the final document off the template and emailed the file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.