Wrong SendDate in the sent emails added from EML to PST

Hello,


First of all, though right now I’m only evaluating your product (ASPOSE.EMAIL) for a future product which I really hope that it will turn into a final project, I’m having a small issue in putting back an EML message saved to disk to a PST file. My scenario works in 99% of the cases and your product is great - it does what is supposed to do in only few lines of code - so 99,99% your library it will be my choice.

The issue is that I’m having some messages (only from the sent items folder) that when are being put back into the PST, they are missing some properties (sending date and sender name) - is not your fault - it seems that is somehow related with the sender client application - doesn’t matter. What it matters is that I’m having these missing pieces into a databases and when I’m putting back the EML into PST, if something is missing I’m able to get the required info - so far so good.

If I’m having the sender info missing, I’m using a piece of code found on this forum and it works great but when I’m trying to put the sending date back to the message I’m having some issues.

Even if I’m setting only the MapiPropertyTag.PR_CLIENT_SUBMIT_TIME or also MapiPropertyTag.PR_DELIVER_TIME, the Outlook displays in the list of messages the time when that message has been put back into the PST, BUT (there is a very big BUT) - on the right pane - the details pane - I’m seeing the correct Date that I set in my code. Please, can you tell me what other properties I have to set in order to have also the date displayed in the messages’ list correct?

The code that I’m using for setting a date is the following:

public static void SetDatePropertyValue(this MapiMessage message, long mapiTag, DateTime dateTimeValue)
{
MapiProperty propertyToSet = new MapiProperty(mapiTag, ConvertDateTimeToMailDateTime(dateTimeValue));
message.SetProperty(propertyToSet);
}

Hi Evdin,


Thank you for your interest in Aspose.Email API.

Please try setting both these properties and this should help you achieving what you want. We have tested the same at our end using the following sample code and it changes the date time in the left side messages list to our desired value. Please try it at your end and let us know your feedback.

Sample Code:

static void Check_827888()
{
MapiMessage msg = MapiMessage.FromFile(“827888\My Subject.msg”);

MapiProperty ClientSubmitTime = new MapiProperty(MapiPropertyTag.PR_CLIENT_SUBMIT_TIME, convertDateTime(new DateTime(2013, 9, 11))); //changes datetime in detail window to the right
msg.SetProperty(ClientSubmitTime);
MapiProperty DeliveryTime = new MapiProperty(MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME, convertDateTime(new DateTime(2013, 9, 11)));
msg.SetProperty(DeliveryTime);

File.Delete(“827888\out.pst”);
PersonalStorage pst = PersonalStorage.Create(“827888\out.pst”, FileFormatVersion.Unicode);

FolderInfo fi = pst.RootFolder.AddSubFolder(“T1”);

fi.AddMessage(msg);

pst.Dispose();
}

private static byte[] convertDateTime(DateTime t)
{
long filetime = t.ToFileTime();
byte[] d = new byte[8];
d[0] = (byte)(filetime & 0xFF);
d[1] = (byte)((filetime & 0xFF00) >> 8);
d[2] = (byte)((filetime & 0xFF0000) >> 16);
d[3] = (byte)((filetime & 0xFF000000) >> 24);
d[4] = (byte)((filetime & 0xFF00000000) >> 32);
d[5] = (byte)((filetime & 0xFF0000000000) >> 40);
d[6] = (byte)((filetime & 0xFF000000000000) >> 48);
d[7] = (byte)(((ulong)filetime & 0xFF00000000000000) >> 56);
return d;
}

Thank you very much!

This is what I did and it worked like a charm :slight_smile:

Thank you very much.
Evdin

Hi Evdin,


You are welcome. Please feel free to write to us if you have any further query related to the API. We’ll be glad to assist you further.