We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incomplete mht file when saving a calendar event

Hi, when i save the attached outlook calendar event to mht, the mht preview is not complete.
Attached are :

  • event_ko.msg : original event
  • event_ko.mht : incomplete mht generated by aspose
  • event_ko.rtf : rtf saved from outlook

For another calendar event, it works fine :

  • event_ok.msg : original event
  • event_ok.mht : correct mht generated by aspose
  • event_ok.rtf : rtf saved from outlook

i use aspose.email.dll v18.10 for .net.

samples_msg.zip (107.6 KB)

here is the code :

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;

using Aspose.Words;
using Aspose.Words.Saving;
using Aspose.Email;

namespace MsgToPdf
{
class Program
{
static void Main(string[] args)
{
Aspose.Email.License licm = new Aspose.Email.License();
licm.SetLicense(“d:\temp\Aspose.Total.lic”);
Aspose.Words.License licw = new Aspose.Words.License();
licw.SetLicense(“d:\temp\Aspose.Total.lic”);
try
{
MailMessage message = MailMessage.Load(“d:\temp\samples_msg\event_ko.msg”);
// If mail date is to be printed according to the local system timezone,
// subtract the mail timezone offset from mail date and your local system timezone
TimeZone localZone = TimeZone.CurrentTimeZone;
TimeSpan ts = localZone.GetUtcOffset(DateTime.Now);
message.Date = message.Date - message.TimeZoneOffset + ts;

// MhtSaveOptions mhtOptions = new Aspose.Email.MhtSaveOptions();
// mhtOptions.MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress;
MhtSaveOptions mhtOptions = Aspose.Email.SaveOptions.DefaultMhtml; //new Aspose.Email.MhtSaveOptions();
mhtOptions.MhtFormatOptions = MhtFormatOptions.WriteHeader | MhtFormatOptions.WriteCompleteEmailAddress | MhtFormatOptions.RenderCalendarEvent | MhtFormatOptions.RenderTaskFields | MhtFormatOptions.RenderVCardInfo;
mhtOptions.SkipInlineImages = true;

            mhtOptions.FormatTemplates[MhtTemplateName.From] = mhtOptions.FormatTemplates[MhtTemplateName.From].Replace("From", "De");
            mhtOptions.FormatTemplates[MhtTemplateName.Cc] = mhtOptions.FormatTemplates[MhtTemplateName.Cc].Replace("Cc", "Cc");
            mhtOptions.FormatTemplates[MhtTemplateName.Bcc] = mhtOptions.FormatTemplates[MhtTemplateName.Bcc].Replace("Bcc", "Bcc");
            mhtOptions.FormatTemplates[MhtTemplateName.To] = mhtOptions.FormatTemplates[MhtTemplateName.To].Replace("To", "A");
            mhtOptions.FormatTemplates[MhtTemplateName.Subject] = mhtOptions.FormatTemplates[MhtTemplateName.Subject].Replace("Subject", "Objet");
            mhtOptions.FormatTemplates[MhtTemplateName.Sent] = mhtOptions.FormatTemplates[MhtTemplateName.Sent].Replace("Sent", "Envoyé le");
            mhtOptions.FormatTemplates[MhtTemplateName.DateTime] = "ddd dd MMM yyyy HH:mm:ss";
            mhtOptions.FormatTemplates[MhtTemplateName.Attachments] = mhtOptions.FormatTemplates[MhtTemplateName.Attachments].Replace("Attachments", "Pièces jointes");
            mhtOptions.FormatTemplates[MhtTemplateName.ShowTimeAs] = mhtOptions.FormatTemplates[MhtTemplateName.ShowTimeAs].Replace("Show Time As", "Afficher la disponibilité");
            mhtOptions.FormatTemplates[MhtTemplateName.Location] = mhtOptions.FormatTemplates[MhtTemplateName.Location].Replace("Location", "Emplacement");
            mhtOptions.FormatTemplates[MhtTemplateName.Start] = mhtOptions.FormatTemplates[MhtTemplateName.Start].Replace("Start", "Début");
            mhtOptions.FormatTemplates[MhtTemplateName.End] = mhtOptions.FormatTemplates[MhtTemplateName.End].Replace("End", "Fin");
            mhtOptions.FormatTemplates[MhtTemplateName.Importance] = mhtOptions.FormatTemplates[MhtTemplateName.Importance].Replace("Importance", "Importance");
            mhtOptions.FormatTemplates[MhtTemplateName.Organizer] = mhtOptions.FormatTemplates[MhtTemplateName.Organizer].Replace("Organizer", "Organisateur");
            mhtOptions.FormatTemplates[MhtTemplateName.Recurrence] = mhtOptions.FormatTemplates[MhtTemplateName.Recurrence].Replace("Recurrence", "Périodicité");
            mhtOptions.FormatTemplates[MhtTemplateName.RecurrencePattern] = mhtOptions.FormatTemplates[MhtTemplateName.RecurrencePattern].Replace("Recurrence Pattern", "Critère de périodicité");
            mhtOptions.FormatTemplates[MhtTemplateName.RequiredAttendees] = mhtOptions.FormatTemplates[MhtTemplateName.RequiredAttendees].Replace("Required Attendees", "Participants obligatoires");


            message.Save("d:\\temp\\samples_msg\\event_ko.mht", mhtOptions);
            GC.Collect();
        }
        catch (System.Exception ex)
        {
            String errmsg = ex.Message + " | " + ex.StackTrace;
            GC.Collect();
        }

    }
}

}

@tparassin

We have reproduced the issue and it has been logged with ID “EMAILNET-39165” for further investigation. You will automatically be informed here once we have more information to share.

The issues you have found earlier (filed as EMAILNET-39165) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan