Java Email (with image links) to PDF conversion takes 30 minutes

We are reading mailboxes, picking up the emails and converting each email to PDF (and processing the attachments too). We first convert the email to mhtml using MailMessage, then convert from mhtml to PDF using Words.

For most emails this is fine and fairly quick. For the occasional email this can take about 30 minutes. After a lot of investigation I have noticed that one of the offending emails has several image links. The server the code is running on probably has internet access blocked and I wonder if the code is just waiting a long time for each image to download via the image link.

I don’t care about the these images from links, but it taking 30 minutes is a real problem.

Could my suspicion be correct, and if so, how might I ignore these image links?

Thanks in advance, Mark.

@mawheadon,

Please debug your code to determine if you are facing this problem during email to .mhtml conversion or .mhtml to .pdf conversion? If this is happening during .mhtml to .pdf conversion, then you can try HtmlLoadOptions.WebRequestTimeout to workaround this problem. Or you can implement IResourceLoadingCallback Interface to skip loading of external resources (images, stylesheets etc). In case the problem still remains, then please ZIP and upload your input email message file and piece of source code here for testing. We will then investigate the issue on our end and provide you more information.