How to get the received time via IMAP?

Hello

How do I get the received date time from an email via IMAP (Aspose.Email v6.2.0.0)?

The following code retrieves the received date:

ImapClient client = new ImapClient(“[imap.domain.com](http://imap.domain.com/)”, 143, "user@domain.com", “password”, SecurityOptions.Auto);

client.SelectFolder(ImapFolderInfo.InBox);

ImapMessageInfoCollection coll = client.ListMessages();

foreach(ImapMessageInfo info in coll)

{

MailMessage mail = client.FetchMessage(info.SequenceNumber);

string receivedDateTime = mail.Headers["Received"].ToString();

}

The receivedDateTime variable contains a string like:

from AM2PR05MB1027.eurprd05.prod.outlook.com (10.161.234.152) by AM2PR05MB1025.eurprd05.prod.outlook.com (10.161.234.150) with Microsoft SMTP Server (TLS) id 15.1.409.15 via Mailbox Transport; Mon, 15 Feb 2016 10:40:16 +0000,from AM2PR05MB1025.eurprd05.prod.outlook.com (10.161.234.150) by AM2PR05MB1027.eurprd05.prod.outlook.com (10.161.234.152) with Microsoft SMTP Server (TLS) id 15.1.409.15; Mon, 15 Feb 2016 10:40:15 +0000,from AM2PR05MB1025.eurprd05.prod.outlook.com ([10.161.234.150]) by AM2PR05MB1025.eurprd05.prod.outlook.com ([10.161.234.150]) with mapi id 15.01.0409.017; Mon, 15 Feb 2016 10:40:15 +0000

How I am supposed to filter out the date received?
Is this a bug or is there another way to retrieve the received date?

Best regards

Andreas

Hi Andreas,


Thank you for contacting Aspose support team.

Although Received header contains the time information as well, but currently there is no mechanism available to extract time from this header. Delivery-Date is the actual header which can be used to retrieve this information if available in the headers list. Thus you may opt for your own logic to parse the Received header in the absence of Delivery-Date header.

Should you have any other query in this regard, feel free to write us back.