Class: GmailRubyUtilities
- Inherits:
-
Object
- Object
- GmailRubyUtilities
- Defined in:
- lib/gmailRubyUtilities.rb
Class Method Summary collapse
- .getCountOfEmailsWithRecipientId(username, password, recipient) ⇒ Object
- .markAllEmailsAsRead(username, password, sender) ⇒ Object
- .readHtmlPartOfLatestMailFromGmail(username, password, sender) ⇒ Object
- .readLinkFromLatestMailFromGmail(username, password, sender) ⇒ Object
- .readTextPartOfLatestMailFromGmail(username, password, sender) ⇒ Object
- .sendEmail(username, password, emailId, subject, body) ⇒ Object
Class Method Details
.getCountOfEmailsWithRecipientId(username, password, recipient) ⇒ Object
37 38 39 40 |
# File 'lib/gmailRubyUtilities.rb', line 37 def self.getCountOfEmailsWithRecipientId(username,password,recipient) gmail = Gmail.connect(username, password) puts gmail.inbox.count(:to => recipient) end |
.markAllEmailsAsRead(username, password, sender) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gmailRubyUtilities.rb', line 20 def self.markAllEmailsAsRead(username,password,sender) gmail = Gmail.connect(username, password) gmail.inbox.find(:from =>sender,:unread=> true ).each do |email| email.read! end end |
.readHtmlPartOfLatestMailFromGmail(username, password, sender) ⇒ Object
9 10 11 12 13 |
# File 'lib/gmailRubyUtilities.rb', line 9 def self.readHtmlPartOfLatestMailFromGmail(username,password,sender) gmail = Gmail.connect(username, password) mail=gmail.inbox.find(:from => sender,:unread=> true).last htmlPart=mail.html_part.decoded end |
.readLinkFromLatestMailFromGmail(username, password, sender) ⇒ Object
4 5 6 7 8 |
# File 'lib/gmailRubyUtilities.rb', line 4 def self.readLinkFromLatestMailFromGmail(username,password,sender) gmail = Gmail.connect(username, password) mail=gmail.inbox.find(:from => sender,:unread=> true).last linkInTheEmail=mail.html_part.decoded.scan(/<a.+?href="(.+?)".+?/)[0] end |
.readTextPartOfLatestMailFromGmail(username, password, sender) ⇒ Object
14 15 16 17 18 |
# File 'lib/gmailRubyUtilities.rb', line 14 def self.readTextPartOfLatestMailFromGmail(username,password,sender) gmail = Gmail.connect(username, password) mail=gmail.inbox.find(:from => sender,:unread=> true).last textPart=mail.text_part.decoded end |
.sendEmail(username, password, emailId, subject, body) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gmailRubyUtilities.rb', line 27 def self.sendEmail(username,password,emailId,subject,body) gmail = Gmail.connect(username, password) email = gmail.compose do to emailId subject subject body body end email.deliver! end |