P
planetthoughtful
Hi,
I'm a newcomer to Ruby in general and to the Gmailer (version 0.1.5)
class in particular, and I wanted to ask a couple of questions about
using it, if that's okay?
In particular, I'm using it across a dialup connection and while I am
successfully connecting to and retrieving message content from gmail
using the gmailer class, it's very slow and it often times out on my
end. Why I don't simply blame this on my connection speed is that
using a browser to access gmail is still slow, but is also generally
faster than the gmailer class via Ruby.
Is that to be expected? The error message I'm getting is below:
c:/ruby/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired
(Timeout::Error)
from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:2017:in
`read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:2006:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:1047:in `request'
... 8 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/gmailer-0.1.5/gmailer.rb:
1570:in `each_msg'
from gmail.rb:15
from c:/ruby/lib/ruby/gems/1.8/gems/gmailer-0.1.5/gmailer.rb:
1784:in `connect'
from gmail.rb:10
I've tried looking for a timeout setting for the gmailer class, but
nothing leaps out at me from the associated readme file.
Second, is there a way of using the each_msg method to, for example,
retrieve all of the unread messages in my account's inbox without
marking those messages as read?
I ask because I have a couple of gmail accounts that I don't access
regularly, but it would be nice to write a script in Ruby using
gmailer that logs in and pulls down a summary of the unread messages
sitting in the inboxes of those accounts. I'd like to leave those
messages with a status of being unread, though, so that this still
stands out when I do log into the accounts using my browser.
For some reason, when I use the each_msg method to iterate through
unread messages, the messages get marked as read. So as it stands
right now, I'm explicitly setting the messages back to being unread
(which is probably adding to the execution time of the script), but
I'm wondering if there's a way to iterate through all the unread
messages in your inbox and retrieve, for example, the sender's email
address and the subject line without marking the message as having
been read?
This is the code I'm using:
require 'gmailer'
GMailer.connect('mygmailaccount', 'mypassword') do
|g|
g.messagesstandard=>'Inbox',:read=>false) {|ml|
puts "Total # of unread messages = " + ml.total.to_s
}
g.messagesstandard=>'Inbox',:read=>false).each_msg {
|ml|
puts "Subject: " + ml.subject + " (" + ml.id.to_s + ")"
g.mark_unread(ml.id)
}
end
Thanks in adance for any help!
Much warmth,
pt
I'm a newcomer to Ruby in general and to the Gmailer (version 0.1.5)
class in particular, and I wanted to ask a couple of questions about
using it, if that's okay?
In particular, I'm using it across a dialup connection and while I am
successfully connecting to and retrieving message content from gmail
using the gmailer class, it's very slow and it often times out on my
end. Why I don't simply blame this on my connection speed is that
using a browser to access gmail is still slow, but is also generally
faster than the gmailer class via Ruby.
Is that to be expected? The error message I'm getting is below:
c:/ruby/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired
(Timeout::Error)
from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:2017:in
`read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:2006:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:1047:in `request'
... 8 levels...
from c:/ruby/lib/ruby/gems/1.8/gems/gmailer-0.1.5/gmailer.rb:
1570:in `each_msg'
from gmail.rb:15
from c:/ruby/lib/ruby/gems/1.8/gems/gmailer-0.1.5/gmailer.rb:
1784:in `connect'
from gmail.rb:10
I've tried looking for a timeout setting for the gmailer class, but
nothing leaps out at me from the associated readme file.
Second, is there a way of using the each_msg method to, for example,
retrieve all of the unread messages in my account's inbox without
marking those messages as read?
I ask because I have a couple of gmail accounts that I don't access
regularly, but it would be nice to write a script in Ruby using
gmailer that logs in and pulls down a summary of the unread messages
sitting in the inboxes of those accounts. I'd like to leave those
messages with a status of being unread, though, so that this still
stands out when I do log into the accounts using my browser.
For some reason, when I use the each_msg method to iterate through
unread messages, the messages get marked as read. So as it stands
right now, I'm explicitly setting the messages back to being unread
(which is probably adding to the execution time of the script), but
I'm wondering if there's a way to iterate through all the unread
messages in your inbox and retrieve, for example, the sender's email
address and the subject line without marking the message as having
been read?
This is the code I'm using:
require 'gmailer'
GMailer.connect('mygmailaccount', 'mypassword') do
|g|
g.messagesstandard=>'Inbox',:read=>false) {|ml|
puts "Total # of unread messages = " + ml.total.to_s
}
g.messagesstandard=>'Inbox',:read=>false).each_msg {
|ml|
puts "Subject: " + ml.subject + " (" + ml.id.to_s + ")"
g.mark_unread(ml.id)
}
end
Thanks in adance for any help!
Much warmth,
pt