Free Support Forum - aspose.com

Extremely long load time for Document()

Greetings,

When attempting to load EML into a word document we are seeing times of 3+ minutes for the Words Document(stream) constructor to complete.

One thing I noticed when test was that it appeared Aspose was going out to the web looking for something.

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required. Is it possible for this proxy to hang inside of Aspose and cause these long load times?

The EML file is 1,734kb which contains 2 PDF attachments 874kb and 362kb.

We are actively working with our customer to gain permission to share these email files with you and working on a test application but I wanted start the conversation now and see if there was any insight you could provide as to what is going on with the proxy.

Hi there,

Thanks for your inquiry. Please note that Aspose.Words does not import EML into its DOM. You need to convert EML to MHTML using Aspose.Email and then load MHTML into Aspose.Words.Document.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input EML/MHTML document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

Hi Tahir,

I failed to mention, yes we convert it to mhtml before passing it to the Words constructor.

Sometimes the emails we import will have links to external images, is there a way to tell the words constructor that if the image is not embedded to ignore it? If not can this be added as a feature?

A lot of the times our customers are in secure environments and our server might have certain firewall restrictions and can’t quickly browse the web which ends up timing our clients out.

We are still working on trying to get sample emails but due to the sensitive nature it’s rather difficult.

Thanks!

@mayswitch,

Thanks for your inquiry. Please use HtmlLoadOptions.ResourceLoadingCallback property to allows to control how external resources (images, style sheets) are loaded when a document is imported from HTML, MHTML.

You may also use HtmlLoadOptions.WebRequestTimeout to set number of milliseconds to wait before the web request times out. Please check the following code example. Hope this helps you.

public class HandleResourceLoading : IResourceLoadingCallback
{
    public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)
    {
        //ResourceLoadingArgs.OriginalUri
        if (args.ResourceType == ResourceType.Image)
            return ResourceLoadingAction.Skip;

        return ResourceLoadingAction.Default;
    }
}

Aspose.Words.HtmlLoadOptions loadOptions = new Aspose.Words.HtmlLoadOptions();
loadOptions.ResourceLoadingCallback = new HandleResourceLoading();

Document doc = new Document(@"C:\Temp\in.mhtml", loadOptions);
doc.Save(@"C:\Temp\out.docx");