MailMessageImportRelatedFiles Method
Adds all the related files (referenced in HTML part of the message) as inline attachments.

Namespace: MailBee.Mime
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public bool ImportRelatedFiles(
	ImportRelatedFilesOptions options


Type: MailBee.MimeImportRelatedFilesOptions
The additional options which affect how the files related to the HTML body are added to the message.

Return Value

Type: Boolean
true if the related files were successfully added as inline attachments; otherwise, false.
MailBeeExceptionAn error occurred and ThrowExceptions is true.

All links to the related files (external documents which are referenced in BodyHtmlText) are replaced with Content-IDs generated for these files when they were attached.

To detect which URIs in the HTML body reference resources which can be added as related files to the message, MailBee examines each URI and checks if it's a web resource or local file system resource. Web resources are ignored unless ImportFromUris option is specified. If the URI contains absolute path on the filesystem, this path is used to load the file. If the URI contains relative path, MailBee by gets the file from MailMessage.Builder.RelatedFilesFolder location. If MailBee was unable to find a resource based on the denoted by the given URIs, such URI is left intact and the inline attachment for that URI is not added.

OnReplaceUriWithCid delegate provides an additional control on which referenced resources get imported and which are not.

This sample generates a new mail message from HTML file and sends it.
using System.IO;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;

class Sample
    static void Main(string[] args)
        // Load the HTML content from the specified file.
        string textHtml = string.Empty;
        using (StreamReader sr = new StreamReader(@"C:\Temp\web_page.htm"))
            textHtml = sr.ReadToEnd();

        // Create a new message and set HTML body of this message.
        MailMessage msg = new MailMessage();
        msg.BodyHtmlText = textHtml;

        // Import all related files from URIs and then send the message.
See Also