@SaTores
Thanks for your inquiry. We investigated the issue and found that the images are not displaying due to Server permissions where the images are hosted. Please check error image for your reference. https://imgur.com/a/Kvzt6Ju.
Please use the following workaround and provide network credentials where the images are hosted. Hope, this helps.
using(MailMessage mailMessage = MailMessage.Load(@ "..\..\MessageFile.msg")) {
using(MemoryStream mhtmlDocumentStream = new MemoryStream()) {
var saveOptions = SaveOptions.CreateSaveOptions(MailMessageSaveType.MHtmlFormat);
mailMessage.Save(mhtmlDocumentStream, saveOptions);
ImageLoadingWithCredentialsHandler imageLoadingWithCredentialsHandler = new ImageLoadingWithCredentialsHandler();
Aspose.Words.LoadOptions loadOption = new Aspose.Words.LoadOptions();
loadOption.ResourceLoadingCallback = imageLoadingWithCredentialsHandler;
var wordDocument = new Aspose.Words.Document(mhtmlDocumentStream, loadOption);
using(MemoryStream outputDocumentStream = new MemoryStream()) {
wordDocument.Save("D:\\Temp\\NewDocument.xps", global::Aspose.Words.SaveFormat.Xps);
}
}
}
public class ImageLoadingWithCredentialsHandler: IResourceLoadingCallback {
public ImageLoadingWithCredentialsHandler() {
mWebClient = new WebClient();
}
public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args) {
if (args.ResourceType == ResourceType.Image) {
Uri uri = new Uri(args.Uri);
if (uri.Host == "www.aspose.com")
mWebClient.Credentials = new NetworkCredential("User1", "akjdlsfkjs");
else
mWebClient.Credentials = new NetworkCredential("SomeOtherUserID", "wiurlnlvs");
// Download the bytes from the location referenced by the URI.
byte[] imageBytes = mWebClient.DownloadData(args.Uri);
args.SetData(imageBytes);
return ResourceLoadingAction.UserProvided;
} else
{
return ResourceLoadingAction.Default;
}
}
private WebClient mWebClient;
}