c# wpf how to preview attachment(word, pdf) not use office online, Microsoft.Office.Interop

72 Views Asked by At

I want to prieview attachment in my wpf application

I cannot user web, I use this application in my local network

I try GemBox.Pdf、spire and aspose, there charge, thank you 3 I want to prieview attachment in my wpf application

I cannot user web, I use this application in my local network

I try GemBox.Pdf、spire and aspose, there charge, thank you 3 f

1

There are 1 best solutions below

0
Atir Tahir On

You can render/preview Email attachments (e.g. Word, PDF) using GroupDocs.Viewer for .NET as follows (API allows to render or generate source file previews in HTML, PDF or Image formats):

// Specify attachment.
Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); 
// Create a stream for attachment.
MemoryStream attachmentStream = new MemoryStream();
//Save attachment
using (Viewer viewer = new Viewer("sample.msg"))
{
    viewer.SaveAttachment(attachment, attachmentStream); 
}
// Render attachment
using (Viewer viewer = new Viewer(attachmentStream))
{
    HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources();
    viewer.View(options);
}

API supports listing and extracting/saving attachments as well. It's a stand-alone backend API that can be integrated in your C# WPF application. Please take a look at this open-source console application.

PS. I am working as Support developer/Evangelist at GroupDocs.