Converting EML to MSG fails for Calendar items

I have an EML file which contains a mime body of “text/calendar”. Essentially this is a calendar item. The EML is appropriately formatted and renders in Outlook.

To convert the file, I’m performing the following:

MailMessage mail = MailMessage.load("");
SaveOptions options = SaveOptions.getDefaultMsgUnicode();

try(FileOutputStream fos : new FileOutputStream("")) {
mail.save(fos, options);
}

When API creates the MSG file without error but then I can’t open the file in Outlook. I’ve attached the EML file and the MSG file that your code created.

@cviaggi,

Please share your sample input files with us for further investigation at our end.

aspose-calendar-sample.zip (7.5 KB)

Attached is the sample EML with the converted MSG.

@cviaggi,

This works at our end with the latest version of AsposeEmail for Java 17.10. Please try with it and let us know your feedback.

I tested it with Java 17.10 and it does work. However, can you please explain how the date conversions are done in the objects?

When I look at the raw iCalendar object I can see these values:
DTSTART;TZID=India Standard Time:20171010T080000
DTEND;TZID=India Standard Time:20171010T083000

When I open the MSG file, I can see that the Mapi Properties are:
0xC5518000 – 08:00:00.000 AM 10/10/2017
0xF633B400 – 08:30:00.000 AM 10/10/2017

I’m assuming that MSG files assume GMT so since the original was IST this seems to be a bug in date conversion? The EML version seems like it’s displaying the dates correctly where it shows:
Monday, October 09, 2017 7:30 PM-8:00 PM

I’ve attached another sample of the original EML and the MSG that I created with your 17.9 version of the API.

Thanks,
//C

cal-test-2.zip (87.6 KB)

@cviaggi,

The EML version seems like it’s displaying the dates correctly where it shows:
Monday, October 09, 2017 7:30 PM-8:00 PM

When we open the attached EML file in MS Outlook, the time isn’t shown in PM as shown in the Screenshot_1.png (164.1 KB)
. After conversion to MSG, it does show a difference of half hour which we believe is related to our timezone. Please help us identify where you observed the time in PM with the help of a screenshot.

PS: Please use the latest version of the API i.e. 17.10 version.

So the conversion was done with 17.9 which was the latest when I downloaded two days ago.

The MSG file was converted from the EML file, so I’m confused as to why the two times would be different. Since the EML was a conversion, shouldn’t they have the same date/times for the meeting? Even though your times were only 30 minutes off, the question then is, which one do you trust? If you were to copy those to your calendar, which is correct?

This screen shot eml-msg-dates.PNG (255.3 KB) shows the EML (on the left) and the MSG (on the right). So while they are both opened with Outlook on my system which has a consistent Timezone, I’m still left wondering which is correct?

If I read the iCalendar text (you can do this by decoding the base64 mime body in the EML), you will see the two lines which I believe dictate the appointment’s start and end time.
DTSTART;TZID=India Standard Time:20171010T080000
DTEND;TZID=India Standard Time:20171010T083000

If you were to take the DTSTART value and assume its GMT, then you get what it says in the MSG file which is 1am PDT. If you take the time as IST then that would seem to correlate with the EML file’s start time.

@cviaggi,

So we changed our Timezone to IST and converted it to MSG file with the latest version of the API. The input EML and output MSG file have the same times displayed now i.e. 7.00 to 7.30 PM with your second sample file. This is the same as if you convert the EML file to MSG using MS Outlook. Please try it with this latest version of the API and let us know your feedback.

Kashif,
If you had to change your time zone so that the calendar dates match doesn’t that seem to indicate that there is something wrong? Otherwise, what you’re telling me is that when I want to convert the an EML->MSG Calendar item, I’ll have to change my timezone to whatever is in the iCalendar portion of the EML.
//C

@cviaggi,

The issue has been logged as EMAILJAVA-34324 for further investigation by our Product team. We’ll update you here once there is some information available in this regard.

@cviaggi,

The issue logged in this thread has been fixed in the latest version of Aspose.Email for Java 17.12. Please download it and let us know if you have any further query in this regard.

I have revisited the conversion with the latest version 17.12 and the resulting conversion creates an MSG file that will not open as an MSG file.

Attached c5.zip (125.7 KB) is a sample of the EML and the resulting MSG file that was created with the following code snippet:

		MailMessage mail = MailMessage.load(tempSaveFilePath);
		SaveOptions options = SaveOptions.getDefaultMsgUnicode();
		try(FileOutputStream fos = new FileOutputStream(saveFilePath)) {
			mail.save(fos, options);
		}

I’m not sure if this is the same bug or something different. The EML definitely is valid and can be opened with Outlook. As a result of this not working, I wasn’t able to verify the fix you posted with 17.12.

Thanks,
//C

@cviaggi,

We have tested the c5.zip and were not able to reproduce the issue at our end. The output MSG file opens fine in MS Outlook. Could you please re-verify if your application is using the 17.12 version of API?