gmailRubyUtilities 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gmailRubyUtilities.rb +33 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331913d28238d1ef37478db0cfb85fdc4fb3ac42
|
4
|
+
data.tar.gz: cddd4e9cd40098408593ae326db22135d81a5977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c6be58ce08a212b7f5d5fd5bf4b1db13036f3f7b7aba667097ec11c4216ca0e972d729fe96464f0bde93d7052d0594fb981d01b70f470de2d2794501355b462
|
7
|
+
data.tar.gz: f6818e6c347ce78337c8a954a23081c234857a95a93dccfbcc92c865c4d6bf8df3ff80287edd47739c300b86fc2993be625af1f7d52368a4ab2ee13b96882c4a
|
data/lib/gmailRubyUtilities.rb
CHANGED
@@ -1,11 +1,40 @@
|
|
1
1
|
class GmailRubyUtilities
|
2
2
|
require 'gmail'
|
3
3
|
|
4
|
-
def self.
|
4
|
+
def self.readLinkFromLatestMailFromGmail(username,password,sender)
|
5
5
|
gmail = Gmail.connect(username, password)
|
6
|
-
|
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
|
-
|
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
|