Render attachments

Rendering email/file attachments in the same way as you would render any other documents.

There are many different use cases when you need to view/preview attachments form an emails, save attachments to specific location, parse or extract attachments. So we made this process easy and simple with GroupDocs.Viewer for .NET API.

GroupDocs.Viewer supports attachments from following formats:

  • Email attachments
  • Outlook attachments
  • Archives
  • PDF

To view attachments just follow steps below:

Following code snippet demonstrates on how to view attachments from MSG file.

Attachment attachment = new Attachment("attachment-word.doc");           
MemoryStream attachmentStream = new MemoryStream();

using (Viewer viewer = new Viewer("sample.msg"))
{
    viewer.SaveAttachment(attachment, attachmentStream); 
}

using (Viewer viewer = new Viewer(attachmentStream))
{
    HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources();
    viewer.View(options);
}