Set html body content from existing html file

Hello
Creating one MailMessage and one MapiMessage and need to set their Html bodies from an existing Html page on my drive.

Using MyMailMessage As New Email.MailMessage
MyMailMessage.SetHtmlBody(“D:\page.html”, True)
End Using

Using MyMapiMessage As New MapiMessage
MyMapiMessage.SetBodyContent(“D:\page.html”, BodyContentType.Html, False)
End Using

  1. MailMessage.SetHtmlBody has a valuable detect encoding parameter, not exist in the MapiMessage.SetBodyContent or MapiMessage.BodyHtml, how about to have it?

  2. In case our input html has all resources embedded inside (as base64 etc) we’re fine, but what if resources are stored in a folder beside the html file? In this case how to properly load the html file into MailMessage and MapiMessage?
    Thanks :slight_smile:

In another Email SDK I use, it’s as easy as ABC:

Load html with resources, no need to set the resources folder, it’s parsed from html itself
MailMessage.LoadBodyText(SourceFile, MessageBodyType.Html, Encoding.UTF8, ImportBodyOptions.ImportRelatedFiles)

Load html with resources, all files refrenced via URIs will be downloaded from their web locations and attached to the message
MailMessage.LoadBodyText(SourceFile, MessageBodyType.Html, Encoding.UTF8, ImportBodyOptions.ImportRelatedFiles Or ImportBodyOptions.ImportRelatedFilesFromUris)

Is anyway here?

  1. Let me know what encoding issues you are experiencing using MapiMessage.SetBodyContent or MapiMessage.BodyHtml?

  2. Here the example to load message from html with resources:

var htmlloadOptions = new HtmlLoadOptions
{
    PathToResources = @"path to res"
};

var eml = MailMessage.Load(@"some.html", htmlloadOptions);

Hello and thanks, seems no way to load html body part with resources?
If so, can you please add a feature request to be able to load html body part from an html file without flexibility and customization? I mean simply enter the path to an html file, the resources should be loaded from the inner elements according to their path values.

Anyway, imagine in a real-world app, user selects an html file, I set @“some.html” to the user input, then for @“path to res” how to find it? Analyze the html file? What if some inner html items had different locations?

@australian.dev.nerds
I have added a future request
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILNET-41136

Hello,
Just a reminder to let you know that this case is a crucial issue, not for me, but your users, all competitor SDKs I’ve tested before were able to set the html body of email by simply enter a path to html file, if file has resources on disk, they will be loaded to the message, if file has remote / online resources, they can be downloaded and inserted to the message optionally.

If html file has different external elements in different paths, most developers will not be interested in doing an html parse job!

Not my case, just a friendly reminder :slight_smile:

Since not only in MailMessage, also MapiMessage:

MapiMessage.SetBodyContent(File.ReadAllText(SourceFile, Encoding.UTF8), BodyContentType.Html, False)

Will not read the html resources.

Thanks for the reminder, we’ll keep that in mind.

1 Like

Hello,
Just wanted to remind you this forgotten case which is pretty important, because it’s very expected for an email SDK to load an html file with resources to the email body :slight_smile:

Hello, I will clarify this issue status and let you know.

1 Like

Hello and thanks,
By the way, does Aspose Email support reading and saving Windows Contacts?
The ones saved in this folder on Win10:
C:\Users\Admin\Contacts

A sample:
gdf ghfd gdf.zip (717 Bytes)

Hello,

no, it is not supported by Aspose.Email.

1 Like