gmailRubyUtilities 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gmailRubyUtilities.rb +33 -4
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5762c5c6fae54d681965009c8d745356891869ce
4
- data.tar.gz: 2aab341108f66e828372a5eee2ef696d79327126
3
+ metadata.gz: 331913d28238d1ef37478db0cfb85fdc4fb3ac42
4
+ data.tar.gz: cddd4e9cd40098408593ae326db22135d81a5977
5
5
  SHA512:
6
- metadata.gz: ad39f617f1ade732618862815d568b1e24da6b25e6da3e8ec8492837b8f2a92a2b87a6b0057a4d0705de79957e93d90d910c578d02f223c321ed4a41d90030c2
7
- data.tar.gz: 2e5052f3b8bfb4aadb3140fad69cccc7328b8a2fcef6274b7d2aced9136964fd3ad5f560a14f3d112ef6935981ce06a9f7b3a0204977f9536339010052743f98
6
+ metadata.gz: 3c6be58ce08a212b7f5d5fd5bf4b1db13036f3f7b7aba667097ec11c4216ca0e972d729fe96464f0bde93d7052d0594fb981d01b70f470de2d2794501355b462
7
+ data.tar.gz: f6818e6c347ce78337c8a954a23081c234857a95a93dccfbcc92c865c4d6bf8df3ff80287edd47739c300b86fc2993be625af1f7d52368a4ab2ee13b96882c4a
@@ -1,11 +1,40 @@
1
1
  class GmailRubyUtilities
2
2
  require 'gmail'
3
3
 
4
- def self.readLatestMailFromGmail(username,password,sender)
4
+ def self.readLinkFromLatestMailFromGmail(username,password,sender)
5
5
  gmail = Gmail.connect(username, password)
6
- numberOfEmails=gmail.inbox.emails(:from => sender).length
7
- mail=gmail.inbox.emails(:from => sender)[numberOfEmails-1]
6
+ mail=gmail.inbox.find(:from => sender,:unread=> true).last
8
7
  linkInTheEmail=mail.html_part.decoded.scan(/<a.+?href="(.+?)".+?/)[0]
9
- return linkInTheEmail
8
+ puts linkInTheEmail
9
+ end
10
+
11
+ def self.readHtmlPartOfLatestMailFromGmail(username,password,sender)
12
+ gmail = Gmail.connect(username, password)
13
+ mail=gmail.inbox.find(:from => sender,:unread=> true).last
14
+ htmlPart=mail.html_part.decoded
15
+ puts htmlPart
16
+ end
17
+ def self.readTextPartOfLatestMailFromGmail(username,password,sender)
18
+ gmail = Gmail.connect(username, password)
19
+ mail=gmail.inbox.find(:from => sender,:unread=> true).last
20
+ textPart=mail.text_part.decoded
21
+ puts textPart
22
+ end
23
+
24
+ def self.markAllEmailsAsRead(username,password,sender)
25
+ gmail = Gmail.connect(username, password)
26
+ gmail.inbox.find(:from =>sender,:unread=> true ).each do |email|
27
+ email.read!
28
+ end
29
+ end
30
+
31
+ def self.sendEmail(username,password,emailId,subject,body)
32
+ gmail = Gmail.connect(username, password)
33
+ email = gmail.compose do
34
+ to emailId
35
+ subject subject
36
+ body body
37
+ end
38
+ email.deliver!
10
39
  end
11
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmailRubyUtilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adarsha