Closed jernelson7 closed 6 years ago
Sorry about the delayed response. I didn't notice this until just now.
The reason that the MimeMessage.Date field is unset is because there is no Date:
header in the message.
Here's the pre-parsed date returned by the server (which is used for the construction of the IMessageSummary
item):
* 1 FETCH (FLAGS ($NotJunk) UID 1 INTERNALDATE "09-Feb-2018 11:46:48 +0000" ENVELOPE (NIL "Welcome to Yahoo!" (("Yahoo Mail" NIL "mail" "product.communications.yahoo.com")) (("Yahoo Mail" NIL "mail" "product.communications.yahoo.com")) ((NIL NIL "replies" "communications.yahoo.com")) ((NIL NIL "tobiidynavoxappdev" "yahoo.com")) NIL NIL NIL "<tobiidynavoxappdev@yahoo.com.02092018114646.yahoo.com>"))
The first argument for the ENVELOPE
value should be a date string, but instead it is NIL
.
The INTERNALDATE
value is the timestamp for when the message was added to the folder and not the same as the Date:
header.
That said, the reason that the IMessageSummary.Date
property has a value is:
/// <summary>
/// Gets the Date header value.
/// </summary>
/// <remarks>
/// Gets the Date header value. If the Date header is not present, the arrival date is used.
/// If neither are known, <see cref="System.DateTimeOffset.MinValue"/> is returned.
/// </remarks>
/// <value>The date.</value>
public DateTimeOffset Date {
get { return Envelope.Date ?? InternalDate ?? DateTimeOffset.MinValue; }
}
That's the logic for the MessageSummary.Date
property.
Hope that helps.
Thanks. Is there a way to get the InternalDate from MimeMessage so I can do the same fallback logic (in case I don't have the message summary) ?
No, the InternalDate is metadata that is not part of a message.
I created a new account on Yahoo for testing. I changed the settings to allow 'less secure apps' for now (planning to do proper OAUTH2.0 authentication later). My code first fetches message summaries and compares to my local database to decide what messages to download*. The message summaries seem to be populated just fine. However, when I query for the full messages (IMailFolder.GetMessage), some of the Dates are empty (DateTime.MinValue). I was expecting to get the same dates that were returned in the IMessageSummary. It looks like the actual date is buried in one of the optional headers ("X-Apparently-To"). Why is the Fetch query able to parse out the date but GetMessage is not? Am I doing something wrong? I suppose I could work around it by using the IMessageSummary Date if necessary, but that's not ideal. The imap.Log is below.