ASP.NET MVC Email – Sending an Email with Attachment from Server Side

asp.net-mvcemailword

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?

Best Answer

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.

Related Topic