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
Using MyMapiMessage As New MapiMessage
MyMapiMessage.SetBodyContent(“D:\page.html”, BodyContentType.Html, False)
MailMessage.SetHtmlBody has a valuable detect encoding parameter, not exist in the MapiMessage.SetBodyContent or MapiMessage.BodyHtml, how about to have it?
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?
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?
Let me know what encoding issues you are experiencing using MapiMessage.SetBodyContent or MapiMessage.BodyHtml?
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?
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