Https url images not displaying for MHtml document when saving as Xps

I’m loading a msg file that contain some external https url images, next I saving this with the MHtml format and loading this to word document to saved to xps.

The https images are not loaded and it seems that it taking to much time trying to resolve those images.

This is how the original message looks:
image.png (39.3 KB)

And this is the Xps conversion:
image.png (28.0 KB)

Console project (31.8 KB)


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.

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 == "")

     mWebClient.Credentials = new NetworkCredential("User1", "akjdlsfkjs");
   mWebClient.Credentials = new NetworkCredential("SomeOtherUserID", "wiurlnlvs");

  // Download the bytes from the location referenced by the URI.

  byte[] imageBytes = mWebClient.DownloadData(args.Uri);


  return ResourceLoadingAction.UserProvided;

 } else
  return ResourceLoadingAction.Default;


private WebClient mWebClient;


thank you for your reply. That’s true some images needs some permissions but that is not the case for all of them. You can open some the images in the browser but still no included in the Xps.


We have checked all available images in your provided document and found that all images are pointing to same server. That is why they are not displayed in XPS. Please check included images URL for your reference.

App Store -
Google Play Store -
Facebook -
Twitter -
Pinterest -
Youtube -
Linkedin -
Logo -

ok, This means that this is not supported? The issue is that those images are public and visible (just click any of those links) but the conversion are NOT including them.


It seems that the following domain is only available for specific region/area and not available globally due to that it shows “Access Denied” message. That is the reason images are not importing to Aspose.Words Document Object Model (DOM) and not displayed in XPS.

Well we do have access to that images and the images are not being included, no sure how this images no available for other regions will affect us if we have access to them.


We are further investigating this issue and will get back to you soon. We apologize for your inconvenience.


Thank you for your patience.

We investigated the scenario further. We were unable to open the images, so we used a VPN. When we tried opening the MSG file using VPN, it failed. Therefore, we created a sample MSG file using the images that opened at our end. We were able to successfully convert the MSG file by using the code snippet that you shared. We have attached the sample MSG and XPS files for your convenience. Please test using the attached MSG file and share your feedback with us. (76.8 KB)