Free Support Forum - aspose.com

Change EMail Header language

Hello,

i want to convert a Mail to PDF, but in the result PDF, the header information (to, from, …) are always in english.

Is there a way to change the language to german or any other language?
I check the issue Email headers in our own language when converting to PDF, but there is no MhtMessageFormatter in current (most recent) Aspose Version.

Kind Regards,m
Andy

@AStelzner

I suggest you to please visit the following thread link for MhtFormatter class usage.

Hi,

sorry, but i have now …Mail… Namespace, is something missing, any referenced assembly?

image.png (7.7 KB)

Kind Regards,
Andy

@AStelzner

Can you please try using following suggested as MHTFormatter has been moved to MHTSaveOptions.

        public static void testFormatter()
        {
            string file = "Test email.msg";

            MailMessage eml = MailMessage.Load(file, new MsgLoadOptions());

            MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
            CultureInfo culture = CultureInfo.CreateSpecificCulture("de-DE");
            mhtSaveOptions.FormatTemplates[MhtTemplateName.DateTime] = String.Concat(culture.DateTimeFormat.LongDatePattern, " ", culture.DateTimeFormat.ShortTimePattern);
            mhtSaveOptions.FormatTemplates[MhtTemplateName.From] = mhtSaveOptions.FormatTemplates[MhtTemplateName.From].Replace("From:", "De :");
            mhtSaveOptions.FormatTemplates[MhtTemplateName.Sent] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Sent].Replace("Sent:", "Envoyé :");
            mhtSaveOptions.FormatTemplates[MhtTemplateName.To] = mhtSaveOptions.FormatTemplates[MhtTemplateName.To].Replace("To:", "À :");
            mhtSaveOptions.FormatTemplates[MhtTemplateName.Cc] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Cc].Replace("Cc:", "Copie :");
            mhtSaveOptions.FormatTemplates[MhtTemplateName.Subject] = mhtSaveOptions.FormatTemplates[MhtTemplateName.Subject].Replace("Subject:", "Objet :");

            
            eml.Save("test2.msg", mhtSaveOptions);
        }

Hello,

this is the workaround i implemented as “workaround” :slight_smile: and yes, this works :slight_smile:

Kind regards,
Andy

@AStelzner

It’s good to know that suggested sample has provide to be working on your end.