Incorrect Sent Field

Hi,
​This is a regression.
​With Aspose 6.8.0 it was working
​With ​17.5 onwards it is not working.

​We are trying to pass Israel as timezone.

<SIMPLE_DATE_FORMAT>ddd dd-MM-yyyy HH:mm</SIMPLE_DATE_FORMAT>
​<TIMEZONE>Israel</TIMEZONE>
Issue:- ​Instead of showing the name of the day it shows the number of the day in the month.

​Sample code is as follows:-

​ if(timeZone != null && !timeZone.equalsIgnoreCase(“default”))
message.setTimeZoneOffset(TimeZone.getTimeZone(timeZone).getOffset(0)); //required to show “Sent” time based on Locale

String fileName = new File(inputFile).getName();
fileName = fileName.substring(0, fileName.lastIndexOf("."));
fileName = fileName + “-Doc7-” + CTSRandomGenerator.getInstance().getNextRandom();
logger.debug(“File name: " + fileName + " to be transformed” );
mhtFile = strTargetFolder + “\” + fileName + “.mhtml”;

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

if(simpleDateFormat != null && !simpleDateFormat.equalsIgnoreCase(“default”)) {
timeFormatted = new SimpleDateFormat(simpleDateFormat).format(message.getDate());
String time = mhtSaveOptions.getFormatTemplates().get_Item(“Sent”).replace("{0}", timeFormatted);
mhtSaveOptions.getFormatTemplates().set_Item(“Sent”, time);
}
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader | MhtFormatOptions.HideExtraPrintHeader|MhtFormatOptions.DisplayAsOutlook);
message.save(mhtFile, mhtSaveOptions);
right date.png (4.9 KB)
wrong date.png (7.1 KB)

As far as input is considered you can pick any hebrew mail.

​Regards,
​Ankur Vashishtha

@AjeshEMC,

Thank you for contacting Aspose support team.

I have tried to observe the scenario using following sample code and shared sample file but with both the versions Aspose.Email for Java 6.8.0 and 18.1.0 got the same result. Could you please assist us if you have mentioned the working version 6.8.0 correctly? If yes please send us a sample message file which can be used to re-produce this scenario.

MailMessage message = MailMessage.load("CTS-4828.msg");
String simpleDateFormat  = "ddd dd-MM-yyyy HH:mm";
String timeZone = "Israel";
if(timeZone != null && !timeZone.equalsIgnoreCase("default"))
    message.setTimeZoneOffset(TimeZone.getTimeZone(timeZone).getOffset(0)); //required to show "Sent" time based on Locale

String mhtFile = "output.mhtml";

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

if(simpleDateFormat != null && !simpleDateFormat.equalsIgnoreCase("default"))
{
    String timeFormatted = new SimpleDateFormat(simpleDateFormat).format(message.getDate());
    String time = mhtSaveOptions.getFormatTemplates().get_Item("Sent").replace("{0}", timeFormatted);
    mhtSaveOptions.getFormatTemplates().set_Item("Sent", time);
}
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader | MhtFormatOptions.HideExtraPrintHeader|MhtFormatOptions.DisplayAsOutlook);
message.save("output.mhtml", mhtSaveOptions);

CTS-4828.zip (20.7 KB)

Hi kashif,
Please find the sample file.

Save the Date - ¿¿¿ ¿¿¿.zip (11.2 KB)
Regards,
Ankur Vashishtha

@AjeshEMC,

We are afraid that this behavior could not be observed using Aspose.Email for Java 6.8.0 with the sample file Save the Date - ¿¿¿ ¿¿¿.zip. Could you please send us a simple console based project which can be used to re-create this scenario here? Please make it sure that no reference is missing in the sample project.

Hi kashif,
It was working in 6.8 and but it is not working in 17.5 as well as 18.1.
I used the sample code attached by you to reproduce the issue.

CTS-5354.zip (17.1 KB)

Regards,
Ankur Vashishtha

In the above zip you will find the input file as well as renditions using 17.5 and 18.1

@AjeshEMC,

We have again verified this at our end and are not able to observe the problem at our end. We doubt that the issue seems to be environment/culture specific. Could you please share information about your OS and language settings at your end where this issue can be observed?

Hi Kashif,
I have been able to reproduce it on Windows 10 and Windows server 2016 using 17.5 as well as 18.1. Can you please attach the output , you are getting using the input file "Save.msg’, i have attached.

Regards,
Ankur

@AjeshEMC,

Here are the output files generated with “Save.msg” file using Aspose.Email for Java 6.8 and 18.1 for your reference.

Save_18.1.zip (3.0 KB)
Save_6.8.zip (3.0 KB)

Hi Kashif,
It looks like the changes happened after 5.8.0.0
And the sample code is

public static void main(String args[]) throws Exception {

    MailMessage message = MailMessage.load("C:\\Save.msg");
    String simpleDateFormat  = "ddd dd-MM-yyyy HH:mm";
    String timeZone = "Israel";
    if(timeZone != null && !timeZone.equalsIgnoreCase("default"))
        message.setTimeZoneOffset(TimeZone.getTimeZone(timeZone).getOffset(0)); //required to show "Sent" time based on Locale

    String mhtFile = "output.mhtml";

    MhtMessageFormatter mhtlFormat = new MhtMessageFormatter();
    if(simpleDateFormat != null && !simpleDateFormat.equalsIgnoreCase("default"))
        mhtlFormat.setDateTimeFormat(simpleDateFormat);  //required to format "Sent" field time and date
    mhtlFormat.format(message);


    MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();
    mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.None | MhtFormatOptions.HideExtraPrintHeader);
    message.save(mhtFile, mhtSaveOptions);
    message.save("C:\\output_182.mhtml", mhtSaveOptions);
}

I am attaching the sample code along with the rendition showing the day in the sent field.

Regards,
Ankur VashishthaSampleCodePlusrenditon.zip (3.8 KB)

@AjeshEMC,

It seems that formatted date string is not generated properly. You may please give a try to the following sample code and share the feedback.

MailMessage message = MailMessage.load("Save.msg");
String simpleDateFormat  = "ddd dd-MM-yyyy HH:mm";
String timeZone = "Israel";
if(timeZone != null && !timeZone.equalsIgnoreCase("default"))
    message.setTimeZoneOffset(TimeZone.getTimeZone(timeZone).getOffset(0)); //required to show "Sent" time based on Locale

String mhtFile = "output.mhtml";

MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

if(simpleDateFormat != null && !simpleDateFormat.equalsIgnoreCase("default"))
{
    SimpleDateFormat format = new SimpleDateFormat("E dd M yyyy HH:mm");
    String DateToStr = format.format(message.getDate());

    String time = mhtSaveOptions.getFormatTemplates().get_Item("Sent").replace("{0}", DateToStr);
    System.out.println("time = " + time);
    mhtSaveOptions.getFormatTemplates().set_Item("Sent", time);
}
mhtSaveOptions.setMhtFormatOptions(MhtFormatOptions.WriteHeader | MhtFormatOptions.HideExtraPrintHeader|MhtFormatOptions.DisplayAsOutlook);
message.save("Save_18.1.mhtml", mhtSaveOptions);