+2 votes

Hi,
I try to migrate an IMAP mail box on a gmail account.
All is fine but I'd like to keep the original received date of my emails.

The received date in gmail is the upload date.

Can I change this?

by

1 Answer

0 votes

You should use Imap.UploadMessage overload that takes UploadMessageInfo parameter, for example:

public long? UploadMessage(byte[] eml, UploadMessageInfo messageInfo)

You can use this class to specifiy internal server date (this is the date/time that IMAP server got the message):

UploadMessageInfo info = new UploadMessageInfo();
info.Flags.Add(Flag.Seen);
info.SetInternalDate(new DateTime(2016, 10, 25, 05, 03, 41));

long uploaded = (long)client.UploadMessage(eml, info);
by (297k points)
...