Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to View the attached documents which are stored in sql database. The attachments can be of any type word,excel,pdf,image file or mail. How it can be done in winform application? Thanks in advance.

What I have tried:

I could download/view excel and word using Interop namespace but how can I achieve it for mail attachment,pdf and other files?
Posted
Updated 4-Dec-16 22:34pm
v2
Comments
NagaNimesh 11474558 5-Dec-16 3:40am    
do u want to see the attached file in a textbox???
Member 12887041 5-Dec-16 5:40am    
No.Not in the text box. Depending on the file extension, it should open in corresponding application. eg. word or pdf
Richard MacCutchan 5-Dec-16 3:45am    
The same way, you just need to find, or write, a viewer for each document type.
F-ES Sitecore 5-Dec-16 5:15am    
If you execute the file using Process.Start then windows will launch the default viewer for that file type.
Member 12887041 5-Dec-16 5:45am    
Thanks. I am facing issue with opening outlook mail item. Could you please help me with that

1 solution

As Richard said, you can create or get a document viewer for each document type. If there are only a few document formats you have, this may be a suitable solution. However, as you cater for more formats, this does have a tendency to become bulky.

Also, there are a number of commercial packages around that enable viewing of a large number of native formats - one of these may suit your purposes, if you are prepared to pay for it.

Alternatively, you could use the document's native application to "print" a rendition of the document to an XPS file, then use the DocumentViewer class[^] to view the new rendition. We did similar to that in our ECM system, although were a bit more old-school, and used PDF as the rendition. XPS these days is a simpler prospect, but still a bit of work involved.
 
Share this answer
 
Comments
Member 12887041 5-Dec-16 5:48am    
Thanks Mick. I have created doc viewer for required document types but facing issue with outlook mail. Could you please help me with that or code snippet for it.
Midi_Mick 5-Dec-16 5:51am    
https://www.codeproject.com/Tips/712072/Reading-an-Outlook-MSG-File-in-Csharp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900