usmanazizgroupdocs
5/23/2016 - 10:46 AM

GetEmailAttachmentHTMLRepresentation.vb

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

' Setup html conversion options
Dim htmlOptions As New HtmlOptions()
htmlOptions.IsResourcesEmbedded = False

' Init viewer html handler
Dim handler As New ViewerHtmlHandler(config)

Dim info As DocumentInfoContainer = handler.GetDocumentInfo(DocumentName)

' Iterate over the attachments collection
For Each attachment As AttachmentBase In info.Attachments
    Console.WriteLine("Attach name: {0}, size: {1}", attachment.Name, attachment.FileType)

    ' Get attachment document html representation
    Dim pages As List(Of PageHtml) = handler.GetPages(attachment, htmlOptions)
    For Each page As PageHtml In pages
        Console.WriteLine("  Page: {0}, size: {1}", page.PageNumber, page.HtmlContent.Length)
        For Each htmlResource As HtmlResource In page.HtmlResources
            Dim resourceStream As Stream = handler.GetResource(attachment, htmlResource)
            Console.WriteLine("     Resource: {0}, size: {1}", htmlResource.ResourceName, resourceStream.Length)
        Next
    Next