Search code examples
rubyimapgmail-imap

Imap folder only returning a subset of emails with it


The following script only return 1000 messages within from the sent folder when the actual number of sent messages is in the 3000+

How can I get the rest of the messages?

username = ask("Enter your username:  ") { |q| q.echo = true }
password = ask("Enter your password:  ") { |q| q.echo = "*" }
look_in_folder = "[Gmail]/Sent Mail"
save_to_folder = "/Users/penang/Desktop"

puts 'Starting...'
imap = Net::IMAP.new('imap.gmail.com', '993', true)

puts "Logging in as #{username} ..."

imap.login(username, password)

imap.examine(look_in_folder)

mails = imap.uid_search(["FROM", "me"])
puts "Found #{mails.count} mail(s) in folder '#{look_in_folder}'"

Solution

  • There is a solution

    Go to Settings > Labs within Gmail and Enable Advanced IMAP Controls enter image description here

    You should now be able to change the folder size limits in Settings > Forwarding and POP/IMAP

    Advanced IMAP Controls Enabled: Enabled

    Advanced IMAP Controls Disabled (default): Disabled