Setting the datetimeformat for a message used to be done using a MhtMessageFormatter (setting DateTimeFormat). In the latest version MhtMessageFormatter is marked as obsolete: ‘Use method MailMessage.Save with appropriate MhtSaveOptions instead this class’.
I cannot find a DateTimeFormat setting in MhtSaveOptions.
The old code was:
var mhtFormatter = new MhtMessageFormatter();
mhtFormatter.DateTimeFormat = “dd-MM-yyyy H:mm:ss tt”;
mhtFormatter.Format(msg);
How to solve this without using MhtMessageFormatter ?
@h.glasbergen,
You may please use MhtSaveOptions.FormatTemplates to set the formatting as demonstrated in code below and share the feedback.
MailMessage msg = new MailMessage("from@host.com", "to@host.com", "subject", "body");
msg.Date = DateTime.Now;
MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
mhtSaveOptions.FormatTemplates[MhtTemplateName.DateTime] = "dd-MM-yyyy H:mm:ss tt";
msg.Save("output.mhtml", mhtSaveOptions);
Thanks, this is working great.
@h.glasbergen,
You are welcome and feel free to write us back if you have any other query related to Aspose.Email.