usmanazizgroupdocs
5/23/2016 - 10:48 AM

GetEmailAttachmentHTMLRepresentation.cs

// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.GetConfigurations();

// Setup html conversion options
HtmlOptions htmlOptions = new HtmlOptions();
htmlOptions.IsResourcesEmbedded = false;

// Init viewer html handler
ViewerHtmlHandler handler = new ViewerHtmlHandler(config);

DocumentInfoContainer info = handler.GetDocumentInfo(DocumentName);

// Iterate over the attachments collection
foreach (AttachmentBase attachment in info.Attachments)
{
    Console.WriteLine("Attach name: {0}, size: {1}", attachment.Name, attachment.FileType);

    // Get attachment document html representation
    List<PageHtml> pages = handler.GetPages(attachment, htmlOptions);
    foreach (PageHtml page in pages)
    {
        Console.WriteLine("  Page: {0}, size: {1}", page.PageNumber, page.HtmlContent.Length);
        foreach (HtmlResource htmlResource in page.HtmlResources)
        {
            Stream resourceStream = handler.GetResource(attachment, htmlResource);
            Console.WriteLine("     Resource: {0}, size: {1}", htmlResource.ResourceName, resourceStream.Length);
        }
    }
}