Browse our Products

Aspose.Email for .NET 20.7 Release Notes

All Changes

EMAILNET-39876Support for countering endless wait or zombie condiation for Aspose.Email operationsFeature
EMAILNET-39873API hangs on exporting MSG to MHTMLBug
EMAILNET-39885Incorrect parsed EML-File with Aspose.EmailBug
EMAILNET-39874Colors of text are lost in exported MHTBug

Using Timeout for Countering Endless Wait Operations While Saving Message to MHT Format

Sometimes, when processing a corrupted message, an operation may be performed infinitely and thus impair the correct functionality of the application. By using a configurable timeout, you can stop a stuck operation, handle the event, and continue executing the application.

We have added the following members to MhtSaveOptions class:

  • MhtSaveOptions.Timeout - Limits the time in milliseconds of formatting message. The default value is 3000 milliseconds.
  • MhtSaveOptions.TimeoutReached - Raised if timed out while saving to Mhtml.

Code sample:

string fileName = "input.msg";
var mailMessage = MailMessage.Load(fileName);
MemoryStream ms = new MemoryStream();
MhtSaveOptions options = SaveOptions.DefaultMhtml;
options.Timeout = 4000;
options.TimeoutReached += TimeoutHandler;
mailMessage.Save(ms, options);

private void TimeoutHandler(object sender, EventArgs ev)
  // your event handling here