Loading Email (eml / msg) and passing to Word for converting without internet connection results in timeout

Hi Support Team

We are trying to send MSG and EML files to Word via Aspose in an environment that has no Internet connection, in order to finally convert it to PDF.
As soon as it tries to load the content and load certain images or icons from the file, it takes a very long time and causes a timeout.

I have seen other examples in the forum that suggest using this class “HandleResourceLoading” so that it activates or not depending on the content, but none of the suggested examples have worked for us as we are in the email layer and this LoadOption is using Aspose.Word class.

Aspose.Words.Loading.LoadOptions options = new Aspose.Words.Loading.LoadOptions();
options.LoadFormat = LoadFormat.Mhtml;
options.ResourceLoadingCallback = new HandleResourceLoading();

Document doc = new Document(originalFileContent.ConvertToMemoryStream(), options);
doc.Save(msgStream, SaveFormat.Mhtml);

public class HandleResourceLoading implements IResourceLoadingCallback
    public int resourceLoading(ResourceLoadingArgs args)

   if (args.getResourceType() == ResourceType.IMAGE)
         return ResourceLoadingAction.SKIP;
      return ResourceLoadingAction.DEFAULT;

i have also tried to save the content in a doc, but i get an empty document.

My sample code is as follows:

private ConvertResult ConvertInternal(string outputExtension, string fileName, byte[] originalFileContent)
            var result = new ConvertResult();

                var msgStream = new MemoryStream();
                LoadOptions options = new EmlLoadOptions();

                // Check if file is EML
                if (!string.IsNullOrEmpty(fileName) && Path.GetExtension(fileName).ReFormatFileExtension().Equals("EML", StringComparison.InvariantCultureIgnoreCase))
                    options = new EmlLoadOptions();
                    options = new MsgLoadOptions();


                _mailMessage = MailMessage.Load(originalFileContent.ConvertToMemoryStream(), options);
                _mailMessage.Save(msgStream, SaveOptions.DefaultMhtml);

                msgStream.Position = 0;

                // Load the MHTML stream using Aspose.Words for .NET and Save the document as TIFF image
                var wordConverter = new AsposeWordDoc
                    ConverterSettings = _settings

                return wordConverter.ConvertToPdf(fileName, msgStream.ToArray());
            catch (Exception ex)
                Logger.Error("Conversion failed", ex);
                result.Result = Result.Error;
                result.Message = ex.Message;

            return result;

Do you have any suggestion how I can rearrange my code so that I can use this feature of HandleResourceLoading and also distinguish between MSG and EMl and not get empty content.

Many thanks for further ideas and help

Hello @hasanirmak ,

To be able to assist you, we’d appreciate it if you shared MSG and EML files with us to reproduce the issue on our side (with an empty document).

Thank you.

Hi margarita

Its almost impossible to reproduce it, because its just happening in the Customer environment and we tried everthing to be as close as it was possible and still could not reproduce it.

I will try to build the part with HandleResourceLoading for Aspose.Word part and let you know if i need more help.


Hello @hasanirmak,

Thanks for the info. Feel free to contact us if you need further assistance.