MhtmlDocument
OfficeIMO.Mhtml
Represents an MHTML web archive as an HTML document plus its decoded MIME related resources.
Inheritance
- object
- MhtmlDocument
Usage
Explore 2 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 2
- Method MhtmlDocument.Load
- Method MhtmlDocument.LoadAsync
Constructors
public MhtmlDocument(string html, IEnumerable<MhtmlResource>? resources = null, string? contentLocation = null, string? rootContentId = null, string? subject = null, HtmlConversionDocumentOptions? htmlOptions = null) #Creates an MHTML document from HTML and optional related resources.
Parameters
- html string
- resources System.Collections.Generic.IEnumerable<OfficeIMO.Mhtml.MhtmlResource>? = null
- contentLocation string? = null
- rootContentId string? = null
- subject string? = null
- htmlOptions OfficeIMO.Html.HtmlConversionDocumentOptions? = null
Methods
public void ConfigureRenderOptions(HtmlRenderOptions options) #Applies the archive base URI, resource-only URL policy, and embedded-resource resolver to render options. The hyperlink policy is left unchanged. Remote resources absent from the archive are fetched only through the policy's one-hop resolver so every redirect destination is approved before it is requested.
Parameters
- options OfficeIMO.Html.HtmlRenderOptions
public void ConfigureRenderOptions(HtmlRenderOptions options, MhtmlRemoteResourcePolicy? remoteResourcePolicy) #Applies the archive base URI, resource-only URL policy, embedded-resource resolver, and explicit bounded remote-resource policy to render options.
Parameters
- options OfficeIMO.Html.HtmlRenderOptions
- remoteResourcePolicy OfficeIMO.Mhtml.MhtmlRemoteResourcePolicy?
public MhtmlImageEmbeddingResult CreateEmbeddedImageDocumentResult(HtmlRenderOptions? resourceLimits = null, CancellationToken cancellationToken = default) #Creates an independent HTML conversion document whose direct image sources use the matching MIME parts from this archive. It never fetches resources outside the archive. The original MhtmlDocument.HtmlDocument and its render resolver remain unchanged.
Parameters
- resourceLimits OfficeIMO.Html.HtmlRenderOptions? = null
- Optional shared resource byte, count, and request limits. Other render settings are ignored.
- cancellationToken System.Threading.CancellationToken = default
- Stops preparation before the next image is processed.
Returns
MhtmlImageEmbeddingResult The editable document and diagnostics for image sources not embedded.public HtmlRenderResourceResolver CreateResourceResolver() #Creates a resolver that serves only resources embedded in this archive.
Returns
HtmlRenderResourceResolverpublic static OfficeContentSafetyReport InspectContentSafety(byte[] archiveBytes, OfficeContentSafetyOptions? options = null, EmailReaderOptions? mimeOptions = null, CancellationToken cancellationToken = default) #Inspects concealed machine-readable HTML in a bounded MHTML archive.
Parameters
- archiveBytes byte[]
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentSafetyReportpublic static OfficeContentSafetyReport InspectContentSafety(string filePath, OfficeContentSafetyOptions? options = null, EmailReaderOptions? mimeOptions = null, CancellationToken cancellationToken = default) #Inspects concealed machine-readable HTML in a bounded MHTML file.
Parameters
- filePath string
- options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentSafetyReportpublic static MhtmlDocument Load(string path, EmailReaderOptions? mimeOptions = null, HtmlConversionDocumentOptions? htmlOptions = null, CancellationToken cancellationToken = default) #Loads an MHTML archive from a file.
Parameters
- path string
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- htmlOptions OfficeIMO.Html.HtmlConversionDocumentOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
MhtmlDocumentpublic static MhtmlDocument Load(Stream stream, EmailReaderOptions? mimeOptions = null, HtmlConversionDocumentOptions? htmlOptions = null, CancellationToken cancellationToken = default) #Loads an MHTML archive from a caller-owned stream.
Parameters
- stream System.IO.Stream
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- htmlOptions OfficeIMO.Html.HtmlConversionDocumentOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
MhtmlDocumentpublic static async Task<MhtmlDocument> LoadAsync(string path, EmailReaderOptions? mimeOptions = null, HtmlConversionDocumentOptions? htmlOptions = null, CancellationToken cancellationToken = default) #Asynchronously loads an MHTML archive from a file.
Parameters
- path string
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- htmlOptions OfficeIMO.Html.HtmlConversionDocumentOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<MhtmlDocument>public static async Task<MhtmlDocument> LoadAsync(Stream stream, EmailReaderOptions? mimeOptions = null, HtmlConversionDocumentOptions? htmlOptions = null, CancellationToken cancellationToken = default) #Asynchronously loads an MHTML archive from a caller-owned stream.
Parameters
- stream System.IO.Stream
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- htmlOptions OfficeIMO.Html.HtmlConversionDocumentOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<MhtmlDocument>public static OfficeContentCleanupResult RemoveSelectedContent(byte[] archiveBytes, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, EmailReaderOptions? mimeOptions = null, CancellationToken cancellationToken = default) #Removes exact selected concealed HTML findings, then reopens and reinspects the MHTML archive.
Parameters
- archiveBytes byte[]
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentCleanupResultpublic static OfficeContentCleanupResult RemoveSelectedContent(string inputPath, string outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null, EmailReaderOptions? mimeOptions = null, CancellationToken cancellationToken = default) #Atomically writes an explicitly cleaned MHTML artifact.
Parameters
- inputPath string
- outputPath string
- selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection
- options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null
- mimeOptions OfficeIMO.Email.EmailReaderOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
OfficeContentCleanupResultpublic void Save(string path, EmailWriterOptions? options = null) #Saves the archive to a file.
Parameters
- path string
- options OfficeIMO.Email.EmailWriterOptions? = null
public void Save(Stream stream, EmailWriterOptions? options = null) #Saves the archive to a caller-owned stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Email.EmailWriterOptions? = null
public Task<EmailWriteResult> SaveAsync(string path, EmailWriterOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously saves the archive to a file.
Parameters
- path string
- options OfficeIMO.Email.EmailWriterOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<EmailWriteResult>public Task<EmailWriteResult> SaveAsync(Stream stream, EmailWriterOptions? options = null, CancellationToken cancellationToken = default) #Asynchronously saves the archive to a caller-owned stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Email.EmailWriterOptions? = null
- cancellationToken System.Threading.CancellationToken = default
Returns
Task<EmailWriteResult>public byte[] ToBytes(EmailWriterOptions? options = null) #Serializes the archive to deterministic MHTML bytes.
Parameters
- options OfficeIMO.Email.EmailWriterOptions? = null
Returns
byte[]Inherited Methods
Properties
public IReadOnlyList<MhtmlResource> Resources { get; } #Decoded related resources in archive order.
public string? RootContentId { get; } #Root Content-ID without angle brackets, when declared.
public Uri BaseUri { get; } #Base URI used for HTML and related-resource resolution.
public IReadOnlyList<EmailDiagnostic> MimeDiagnostics { get; } #Diagnostics produced by the shared bounded MIME reader.