Module: OnlyofficeIredmailHelper::MailGetters
- Included in:
- IredMailHelper
- Defined in:
- lib/onlyoffice_iredmail_helper/mail_getters.rb
Overview
Modules to get mail by different parameters
Instance Method Summary collapse
-
#email_by_date_and_title(date: Date.today, subject: nil, timeout: 300, move_out: true, range: 1) ⇒ Hash, False
Search email by specific date and message title.
-
#get_html_body_email_by_subject(options = {}, times = 300) ⇒ String
Get email html body by subject.
-
#get_text_body_email_by_subject(options = {}, times = 300) ⇒ String
Get email text body by subject.
Instance Method Details
#email_by_date_and_title(date: Date.today, subject: nil, timeout: 300, move_out: true, range: 1) ⇒ Hash, False
Search email by specific date and message title
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/onlyoffice_iredmail_helper/mail_getters.rb', line 12 def email_by_date_and_title(date: Date.today, subject: nil, timeout: 300, move_out: true, range: 1) start_date = (date - range).strftime('%d-%b-%Y') end_date = (date + range).strftime('%d-%b-%Y') login @imap.select('INBOX') start_time = Time.now while (Time.now - start_time) < timeout @imap.search(['SINCE', start_date, 'BEFORE', end_date]).each do || mail_data = get_mail_data() next unless mail_data[:subject].start_with?(subject) if move_out () else () end return mail_data end end false end |
#get_html_body_email_by_subject(options = {}, times = 300) ⇒ String
Get email html body by subject
54 55 56 57 58 59 |
# File 'lib/onlyoffice_iredmail_helper/mail_getters.rb', line 54 def get_html_body_email_by_subject( = {}, times = 300) mail = mail_by_subject(, times) return nil unless mail mail[:html_body] end |
#get_text_body_email_by_subject(options = {}, times = 300) ⇒ String
Get email text body by subject
43 44 45 46 47 48 |
# File 'lib/onlyoffice_iredmail_helper/mail_getters.rb', line 43 def get_text_body_email_by_subject( = {}, times = 300) mail = mail_by_subject(, times) return nil unless mail mail[:body] end |