MailMessageGetHtmlAndSaveRelatedFiles Method |
Extracts the HTML body of the message, saves the attached inline pictures and other related files to disk, and return the modified HTML body.
Namespace: MailBee.MimeAssembly: MailBee.NET.45 (in MailBee.NET.45.dll) Version: 10.0.45.502
Syntaxpublic string GetHtmlAndSaveRelatedFiles()
Public Function GetHtmlAndSaveRelatedFiles As String
Return Value
Type:
String
A string containing the HTML body which is altered in such a way so that all Content-ID references (
cid:) are replaced with
paths to the related files as they were saved by this method.
Remarks
The inline objects referenced in the HTML body of the message (i.e. embedded objects) are saved into the folder denoted by
MailMessage.Parser.WorkingFolder property.
The links to the embedded objects in the returned HTML data are corrected automatically. The value of
BodyHtmlText property
is left intact.
ExamplesThis sample creates an HTML file from the e-mail message. The related files will also be saved into the same location.
using System.IO;
using MailBee;
using MailBee.Mime;
class Sample
{
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\TestMail.eml");
msg.Parser.WorkingFolder = @"C:\Temp";
using (StreamWriter sw = new StreamWriter(@"C:\Temp\web_page.htm", false))
{
sw.Write(msg.GetHtmlAndSaveRelatedFiles());
}
}
}
Imports System.IO
Imports MailBee
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\TestMail.eml")
msg.Parser.WorkingFolder = "C:\Temp"
Dim sw As StreamWriter
Try
sw = New StreamWriter("C:\Temp\web_page.htm", False)
sw.Write(msg.GetHtmlAndSaveRelatedFiles())
Finally
If Not sw Is Nothing Then
sw.Close()
End If
End Try
End Sub
End Module
See Also