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

Free Support Forum - aspose.com

MhtMessageFormatter obsolete

Hey


We want to update our Aspose.Email from 4.4.0.0 to 17.2.0.0.

Now we face a problem with the obsolet MhtMessageFormatter.

Here is our Function:

private void FormatHeader(MailMessage mailMessage)
{
MhtMessageFormatter messageFormatter = new MhtMessageFormatter();

messageFormatter.FromFormat = messageFormatter.FromFormat.Replace(“From:”, Resources.MailMessage_From);
messageFormatter.SentFormat = messageFormatter.SentFormat.Replace(“Sent:”, Resources.MailMessage_Sent);
messageFormatter.SubjectFormat = messageFormatter.SubjectFormat.Replace(“Subject:”, Resources.MailMessage_Subject);
messageFormatter.ToFormat = messageFormatter.ToFormat.Replace(“To:”, Resources.MailMessage_To);
messageFormatter.CcFormat = messageFormatter.CcFormat.Replace(“Сс:”, Resources.MailMessage_Cc);
messageFormatter.ImportanceFormat = messageFormatter.ImportanceFormat.Replace(“Importance:”, Resources.MailMessage_Importance);
messageFormatter.BccFormat = messageFormatter.BccFormat.Replace(Resources.MailMessage_Bcc, Resources.MailMessage_Bcc);
messageFormatter.AttachmentFormat = messageFormatter.AttachmentFormat.Replace(“Attachments:”, Resources.MailMessage_Attachments);

messageFormatter.Format(mailMessage, MhtFormatOptions.HideExtraPrintHeader);
}

How can we translate the formats without using the obsolete formatter?
I didn’t found anything similar in MhtSaveOptions.

Hi Ismail,


Thank you for posting your concern.

You can use the MhtSaveOptions.FormatTemplates for this purpose as shown in the code sample below. Please try it at your end and let us know your feedback. Keys that can be used for FormatTemplates are as follow:

PageHeader
Location
Start
End
ShowTimeAs
Recurrence
RecurrencePattern
Organizer
RequiredAttendees
DateTime
From
Sent
To
Cc
Bcc
Subject
Attachments

Sample Code:

string emlPath = “38630\BEFORE88460.eml”;
MailMessage mail = MailMessage.Load(emlPath, new EmlLoadOptions());

MhtSaveOptions options = Aspose.Email.Mail.SaveOptions.DefaultMhtml;
options.MhtFormatOptions = MhtFormatOptions.WriteHeader;
options.FormatTemplates[“From”] = options.FormatTemplates[“From”].Replace(“From:”, “Da:”);
options.FormatTemplates[“Sent”] = options.FormatTemplates[“Sent”].Replace(“Sent:”, “Inviato:”);

mail.Save(“38630\outcheck.mhtml”, options);

Hey Kashif


Sry for the late reply.
It worked almost perfectly :smiley:
But there was one problem.

At “Sent:” you added the day by default since 4.4.0.0. I tried to change the language of the day…

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(“de-DE”);

Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(“de-DE”);

System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo(“de-DE”);

…but without result.

Gesendet: Tue, 18 Feb 2014 12:10:28 +0000

Is there a way to change the language of the day or to enter a different format?

Hi Ismail,


We couldn’t find any such option to change the language of Day using the API. It seems these are related to system settings which need to be looked into language settings of the system, though we couldn’t exactly locate the source of such string.