GMail IMAP API limited to first 1000 - gmail

I've bee experimenting with GMail IMAP API using the gmail ruby gem and was unable to pull search results for old emails. More specifically, if I would search for emails about a year ago they would not show up in the search result. This seems consistent with the Mail app on iPhone which also uses IMAP and seems likes its impossible to retrieve old emails.
It seems like this might be related to some limit that Gmail is putting on the IMAP interface which limits it only to the first 1000 emails.
Anybody else can confirm this?
Is there a way around this?

That's settable in gmail. I don't remember whether it's a per-account of per-mailbox setting.

Related

How to fetch messages from specific label(folder) using IMAP in Gmail?

When I list folders I don't have 'snoozed' folder there.
I Googled and it seems like 'snoozed' is sort of internal label that is not available through IMAP (is it correct??). So I want to find where 'snoozed' mails are really kept.
Can I do it using fetch command for instance? How?
There is a really good explanation that this is something that it's not possible in this thread.
Pretty much the Snooze feature is implemented internally within Gmail UI and so Imap clients won't be able to replicate this behavior, therefore you won't be able to find emails snoozed when using a mail client.

Javamail pull messages in chunks (like pagination) GMAIL POP3

Through Java app I am able to connect with GMAIL POP3 server. When I call getMessageCount() it returns me 280, though I have more than 10k mails in my Inbox. So, when I call folder.getMessages(300, 400) it gives me error because range is more than 280. For more details see my another post link
My question is:
Is their any API to get pull emails in chunks (like as pagination)? if so can anyone give me reference to start with it.
This is not a javamail limitation, this is a gmail limitation of their POP3 server. When accessing over POP, it will only show you 300ish messages at a time until you remove them. There is an alternate access method where you specify the login as recent:user#gmail.com, where instead it will show you the last 30 days worth of email.
They do this because POP3 rapidly becomes a very inefficient protocol for accessing thousands of emails, so they limit the window of messages you can see.
If you wish to access all the email, you will need to either switch to IMAP, or use the Gmail REST API, both of which have vastly improved mail access and experiences.

IMAP APPEND with gmail, treat as new incoming email

I have successfully got my nodejs app to IMAP "APPEND" a new message to Gmail, with custom date/time. Everything works fine. But, how do I make Gmail treat it as actual new incoming email? (which needs to be sorted based on existing filters, pushed to spam if needed,etc). Basically all the functions carried out on new incoming email by Gmail. Is there any such event that can be raised on the newly created email, maybe something using its UID? Does Gmail support such functionality through IMAP?
P.S: Using "inbox" npm package. Also tried reading IMAP spec, couldn't understand much. (only got to understand APPEND command part).
No. IMAP Append means 'Put this directly in this folder'. You can use the flags argument of APPEND to make sure you don't mark it \Seen, so it'll look like an unread message.
The only way to make it do all the new email steps and filtering is to send it via SMTP.

searches incoming gmail mails for specific keywords

Can Gmail be set up to search incoming mail, on my android phone, for specific keywords?
Then when a keyword is detected, alert the user with a particular sound?
Iv'e looked through all the gmail settings, but cannot find a way of achieving this, if it's at all possible, that is.
The gmail app for android has a filter that if set up with your gmail labels filter correctly, Will produce a sound of your choice on certain keywords.

Link to individual mails in gmail

I want to download all emails in a gmail account and also want to get the unique url which will open the exact mail in gmail, off course with authentication. I tried using javax.mail imap library but Imap probably doesn't supports anything like it.
I can use "https://mail.google.com/mail/feed/atom" gmail feeds. but won't give me entire email and it only gives unread email and I don't want to miss any email
You can do this if you are using Google Apps for Business/Education. If you are, you can access the Gmail inbox feed (Atom) by using OAuth. OAuth can also be used to access Gmail via IMAP - you can then have complete access to the IMAP server programmatically, see Gmail IMAP and SMTP using OAuth.
Google has extended IMAP to allow developers to provide a more Gmail-like experience via IMAP, see: (Gmail IMAP Extensions, X-GM-EXT-1).
The unique message (X-GM-MSGID) and unique thread (X-GM-THRID) ids can be used to produce links to Gmail messages directly - you just have to hex encode the id long (e.g. Long.toHexString(x_gm_msgId)). Your link will then need need to be in the form of:
http://mail.google.com/mail?account_id=ACCOUNT_ID_HERE&message_id=MESSAGE_ID_HERE&view=conv&extsrc=atom
supplying ACCOUNT_ID_HERE (something like user#someplace.com) and MESSAGE_ID_HERE as appropriate.
I have been working in this area and think you might find my project useful, see: java-gmail-imap.
[NB: URLs formatted as above do not work on Gmail's mobile site (at least on iPhone/Safari).]
https://mail.google.com/mail/#all/HexEncodeMessageID
replace the HexEncodeMessageID part with the ID. You get it, when you open the email in a new window (use the pop out icon in the upper right corner.
The id looks like this: search=inbox&th=1426b8f59e003aa0
I'm fairly confident this is not possible - that there is no reliable way to get the unique URL that'll lead to a single email in Gmail. I'd love to hear otherwise!
I do believe it is possible to get a URL that will lead to the Gmail thread containing the message - but you have no control over which message(s) are "expanded" in this threaded display.

Resources