SmtpMail.ImportHtmlAsync Method


Imports HTML source from string to HTML body of the e-mail message. This method also import linked images/pictures in the HTML source to embedded images.

[Visual Basic]
Public Sub ImportHtmlAsync( _
    source As String, _
    basePath As String, _
    options As ImportHtmlBodyOptions _
)
[C#]
public void ImportHtmlAsync(
    string source,
    string basePath,
    ImportHtmlBodyOptions options
);
[C++]
public: void ImportHtmlAsync(
    String^ source,
    String^ basePath,
    ImportHtmlBodyOptions^ options
);
[JScript]
public function ImportHtmlAsync( 
    source : String,
    basePath : String,
    options : ImportHtmlBodyOptions* options
);

Parameters

source
A html text string.
source
Root path for embedded pictures that uses relative path in html source.
options
Any combination of ImportHtmlBodyOptions values

Example

[Visual Basic, C#, JavaScript] The following example demonstrates how to import remote & local html source with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.

[VB - Import Html Body and Embedded Image]
Dim oMail As SmtpMail = New SmtpMail("TryIt")

'test.gif is in ms-appdata:///local/my picture
Await oMail.ImportHtmlBodyAsync( "<html><body>test <img src=""test.gif""> importhtml</body></html>", _
	"ms-appdata:///local/my picture", _
	ImportHtmlBodyOptions.ImportLocalPictures OR ImportHtmlBodyOptions.ImportCss )

Await oMail.SaveAsAsync( "ms-appdata:///local/test.eml", true )

[C# - Import Html Body and Embedded Image]
SmtpMail oMail = new SmtpMail("TryIt")

await oMail.ImportHtmlAsync( "<html><body>test <img src=\"test.gif\"> importhtml</body></html>",
	"ms-appdata:///local/my picture", //test.gif is in ms-appdata:///local/my picture
	ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportCss );

await oMail.SaveAsAsync( "ms-appdata:///local/test.eml", true );

[JavaScript - Import Html Body and Embedded Image]
var oMail = new EASendMail.SmtpMail("TryIt");

oMail.importHtmlAsync( "<html><body>test <img src=\"test.gif\"> importhtml</body></html>",
	"ms-appdata:///local/my picture", //test.gif is in ms-appdata:///local/my picture
	 EASendMail.ImportHtmlBodyOptions.importHttpPictures | EASendMail.ImportHtmlBodyOptions.importCss )
.then(function(){
    return oMail.saveAsAsync( "ms-appdata///local/test.eml", true );
})
.done(function(){
 
});

See Also

ImportHtmlBodyOptions Enumeration
Attachment Class
SmtpMail.ImportHtmlBodyAsync Method
SmtpMail.HtmlBody Property