Problem with email date search
See original GitHub issueI’ll start by saying that I’m almost sure I’m not using the API properly.
In one of my GMail accounts, I have an unread email from March 22, 2015
.
I’m trying to read its contents, but with no luck. The code is:
var lastDate = new Date(2015, 2, 20); // 2 days before the email's date
imap.search([ ['SINCE', lastDate] ], function(err, results) {
if (err) throw err;
var f = imap.seq.fetch(results, {
bodies: 'TEXT'
});
f.on('message', function(msg, seqno) {
// this never fires
});
[...]
});
I also tried with string representation of the date, with identical results. If I set the date long enough in the past, I can see this email in the list of few emails that belong to the time interval.
Any ideas?
In the debug log, I don’t see any request like the one below, which is extracted from a date filter from January until March.
'* 555 FETCH (X-GM-THRID XXXXXXXXXXXXXXXXX X-GM-MSGID XXXXXXXXXXXXXXXXX X-GM-LABELS ("\\\\Important" "\\\\Sent") UID 562 MODSEQ (XXXXX) INTERNALDATE "31-Jan-2015 20:00:22 +0000" FLAGS (\\Seen) BODY[TEXT] {14}'
Debug info:
[connection] Connected to host
<= '* OK Gimap ready for requests from <IP> <HASH>'
=> 'A0 CAPABILITY'
<= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 AUTH=PLAIN AUTH=PLAIN-CLIENTTOKEN'
<= 'A0 OK Thats all she wrote! <HASH>'
=> 'A1 LOGIN "my_user@gmail.com" "password"'
<= '* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT'
<= 'A1 OK my_user@gmail.com authenticated (Success)'
=> 'A2 NAMESPACE'
<= '* NAMESPACE (("" "/")) NIL NIL'
<= 'A2 OK Success'
=> 'A3 LIST "" ""'
<= '* LIST (\\Noselect) "/" "/"'
<= 'A3 OK Success'
=> 'A4 EXAMINE "<NAME_OF_INBOX>" (CONDSTORE)'
<= '* FLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen $Phishing $NotJunk NotJunk $NotPhishing)'
<= '* OK [PERMANENTFLAGS ()] Flags permitted.'
<= '* OK [UIDVALIDITY 12] UIDs valid.'
<= '* 636 EXISTS'
<= '* 0 RECENT'
<= '* OK [UIDNEXT 660] Predicted next UID.'
<= '* OK [HIGHESTMODSEQ 111910]'
<= 'A4 OK [READ-ONLY] <NAME_OF_INBOX> selected. (Success)'
=> 'A5 UID SEARCH SINCE 20-Mar-2015'
<= '* SEARCH 659'
<= 'A5 OK SEARCH completed (Success)'
=> 'A6 FETCH 659 (X-GM-THRID X-GM-MSGID X-GM-LABELS MODSEQ UID FLAGS INTERNALDATE BODY.PEEK[TEXT])'
<= 'A6 OK Success'
=> 'IDLE IDLE'
<= '+ idling'
=> DONE
<= 'IDLE OK IDLE terminated (Success)'
=> 'A7 LOGOUT'
<= '* BYE LOGOUT Requested'
<= 'A7 OK 73 good day (Success)'
[connection] Ended
[connection] Closed
Thank you
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
wrong date in email search pane - Microsoft Community
When I search my emails (received) the dates are wrong for about 50% of them. Dates from emails in last year or so...
Read more >7 Ways to Troubleshoot If Outlook Search Is Not Working
Make sure Outlook is up to date · 1. In Outlook, click File and then choose Office Account. · 2. On the right...
Read more >How to fix the date search order in Outlook 2016 - YouTube
Sometimes the order that search looks for email starts at the bottom instead of the top. This video shows you how to quickly...
Read more >How to Fix Outlook Search Problems | Comprehensive Guide
Summary: This blog outlines Microsoft Outlook search problems such as ?Outlook search not working? and ?returns no or incomplete results?
Read more >How to Search Gmail by Date [Screenshots Included]
To locate emails received before a certain date, type into the search bar Before:YYYY/MM/DD and press Enter. So, for example, if you want...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the previous debug output you posted:
That shows you used a date of March 20, and it found 1 message that matched your search criteria with a UID of 659. However you then try to fetch a message with a sequence number of 659 instead of the message with a UID of 659. Since you searched for UIDs, you need to use
imap.fetch(uid, ...);
instead ofimap.seq.fetch(uid, ...)
No problem