Adds all the related files (referenced in HTML part of the message) as inline attachments.
true if the related files were successfully added as inline attachments; otherwise, false.
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.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample generates a new mail message from HTML file and sends it.
[C#] 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. msg.ImportRelatedFiles(ImportRelatedFilesOptions.ImportFromUris); Smtp.QuickSend(msg); } }
[Visual Basic] Imports System.IO Imports MailBee Imports MailBee.SmtpMail Imports MailBee.Mime Module Sample Sub Main(ByVal args As String()) ' Load the HTML content from the specified file. Dim textHtml As String = String.Empty Dim sr As StreamReader Try sr = New StreamReader("C:\Temp\web_page.htm") textHtml = sr.ReadToEnd() Finally If Not sr Is Nothing Then sr.Close() End If End Try ' Create a new message and set HTML body of this message. Dim msg As New MailMessage msg.BodyHtmlText = textHtml ' Import all related files from URIs and then send the message. msg.ImportRelatedFiles(ImportRelatedFilesOptions.ImportFromUris) Smtp.QuickSend(msg) End Sub End Module
MailMessage Class | MailBee.Mime Namespace | ImportRelatedFilesOptions | LoadBodyText