How can I get the receiving date from email headers using POP3

0 votes
asked Apr 7, 2016 by microchip86 (120 points)

Hello Rebex team,

I am evaluating the product Rebex Secure Mail in the hope to register it.
I find no possibility to get the 'ReceivedDate' if I retrieve the headers from a email using POP3.

I use the method:
'Pop3MessageInfo messageInfo = popClient.GetMessageInfo(1, Pop3ListFields.FullHeaders)'
Only the 'Date' property I can get.

However I retrieve the email headers using IMAP I get the 'Date' and the 'ReceivedDate'

Is there a way to get the receiving date from a POP3 mail without to retrieve the complete mail?
Or is this planned in future versions?

Thanks

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Apr 7, 2016 by Lukas Pokorny (93,630 points)
edited Jul 1, 2016 by Lukas Pokorny

Update: ReceivedDate property has been added to Pop3MessageInfo in Rebex Secure Mail 2016 R2.


The ReceivedDate value is not part of the message itself. It's only a part of the IMAP protocol's message metadata (it's actually called INTERNALDATE). The POP3 protocol doesn't provide any equivalent functionality, which unfortunately means that it's not possible to retrieve this using POP3 clients.

However, it is possible to retrieve a date from the topmost Received header, which should more-or-less correspond to the ReceivedDate obtained using Imap.GetMessageInfo. The MailMessage object can be used to easily parse the headers and return the desired date:

Pop3MessageInfo info = pop3.GetMessageInfo(sequenceNumber, Pop3ListFields.FullHeaders);

var mail = new MailMessage();
foreach (MimeHeader header in info.Headers)
{
    if (header.Name == "Received")
        mail.Headers.Add(header);
}
MailDateTime receivedDate = mail.ReceivedDate;
...