willyab
willyab

Reputation: 324

gem: mail: how to read email from all folders including inbox

 * mail (2.7.1)
        Summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
        Homepage: https://github.com/mikel/mail
        Path: /home/cb/.gem/ruby/2.6.6/gems/mail-2.7.1

The mail client in use, Thunderbird, has rules on some clients which move mail from the inbox to other specified folders.

Need help to read emails held in folders OTHER THAN inbox, for example, sent, cC etc.

The documentation seems to be silent on this issue.

Upvotes: 0

Views: 254

Answers (1)

willyab
willyab

Reputation: 324

Found the answer in mail/network/retriever_methods/imap.rb where the mailbox to search is set as an option as follows: options[:mailbox]= where options is passed as the only parameter of Mail.find.

By default, it is set to INBOX.

To search the mailbox Sent folder use: options[:mailbox] = 'INBOX.Sent'.

Also, when constructing the search key, use the verb conjunction to as opposed to from in the case of the Sent folder.

Upvotes: 1

Related Questions