Not able to set Date on MSG file like how it display in Outlook Msg File

Hello,
We are unable to set the display of Date how it looks in Outlook when you open an email that is already sent. Please find attached screen how we would like to get it and also the code that we are using to set it. We are using 20.3 version of aspose.email for Java
MSG_File_Display_Date.png (6.0 KB)

MailMessage mailMessage = new MailMessage();
mailMessage.setFrom(new MailAddress(“Sai_Potluri@yahoo.com”));
MailAddressCollection addressCol = new MailAddressCollection();
addressCol.addMailAddress(new MailAddress(“sai.potluri@ihsmarkit.com”));
addressCol.addMailAddress(new MailAddress(“keely.foux@ihsmarkit.com”));
addressCol.addMailAddress(new MailAddress(“jing.luo@ihsmarkit.com”));
mailMessage.setTo(addressCol);
mailMessage.setSubject(“creating an outlook message file”);
mailMessage.setBody(“This message is created by Aspose.Email for Java”);
mailMessage.setDate(new Date());
MhtSaveOptions mhtOptions = new MhtSaveOptions();
mhtOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader);
MapiMessage outlookMsg = MapiMessage.fromMailMessage(mailMessage);
outlookMsg.setDeliveryTime(new Date());
outlookMsg.setMessageFlags(MapiMessageFlags.MSGFLAG_ZERO);
String strMsgFile = “D:\” + “message_out_new_5.msg”;
outlookMsg.save(strMsgFile, SaveOptions.getDefaultMsg());

@sai_potluri,

I have worked with sample code shared by you and have created the message file attached. I have opened the generated MSG file on my end in MS Outlook and it opens fine. The snapshot is attached for your kind reference. Can you please elaborate or share a sample message file that you want to generate using API and we will try make similar one for you.
image.png (21.4 KB)

message_out_new_5.zip (2.1 KB)

Hi Mudassir,
Thanks for your response. Problem is not opening msg file. We are not able to set the date like how I have attached in the screenshot in this message.

MSG_File_Display_Date.png (6.0 KB)

Our requirement is to add Date on the msg file to let users know that our system has sent email on that Date. Any way to display the date on the msg file is highly appreciable.

With Regards,
Sai Krishna.P

@sai_potluri,

Actually,. this is my question. Have you been able to manage to display the date for any message file on your end. I don’t think so there is any possibility. If there is any such Message file with related support, please share with us and I will try to help you further in this regard.

Thanks Mundassir. I tried my best, but cannot do it. Our Project requirement is to have the date displayed as in attached screenshot. Do you think we can check with ASPOSE Paid support for the same.

MSG_File_Display_Date.png (6.0 KB)

@sai_potluri,

I have observed the requirements w.r.t possibilities available in Aspose.Email and suggest you to please try using following sample code on your end.

mailMessage.isDraft(false);

It shows the date in image. Is this sufficient to meet your requirements.

Thank You Savior. It worked Excellent.

@sai_potluri,

It’s good to know that things have worked on your end. Please share, if I may help you further in this regard.

Hi Mudassir,
Can you please share an example of how to create msg file with attachment like doc or images or spreadsheet.

With Regards,
Sai Krishna.P

@sai_potluri,

I have observed your requirements and suggest you to please visit this documentation link for your reference.

Hi Mudassir,

Thanks for the link very useful. Mean time, have a question on setting Date on the msg file.

Is there as way to set the Date in (Tuesday 27/04/20 5:30 PM) on the .msg file overriding the windows system date format and timezone.

In our case it is take System date format and timezone.
Ex:- UTC Date is ‘Wednesday, 29/04/20 01:40 AM’, but if I create a msg file and open it on EST time zone it says ‘Tue 4/28/2020 9:40 PM’.

Sample Code:-
String sDate = “'Wednesday 29/04/20 01:40 AM”;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“EEEEE dd/MM/yy HH:mm a”);
Date date6 = simpleDateFormat.parse(sDate);
mailMessage.setDate(date6);

With Regards,
Sai Krishna.P

@sai_potluri,

MailMessage class has property TimeZoneOffset, if this set then it taken into account when message saved in MHTML or TIFF or XPS format.
However, In MSF format date stored in UTC and displayed in local time zone of machine where it opened.