From: Park Heesob Date: 2005-09-04T08:46:32+09:00 Subject: Re: [ANN] gmailer-0.0.8 released Hi, >From: Daniel Schierbeck >Reply-To: ruby-talk@ruby-lang.org >To: ruby-talk@ruby-lang.org (ruby-talk ML) >Subject: Re: [ANN] gmailer-0.0.8 released >Date: Sun, 4 Sep 2005 02:26:26 +0900 > >One thing that would be cool is a more advanced API. Something along the >lines of this: > >Module GMailer > # the main class. > class Connection > # returns the messages that match the filters > # or all messages if no filter is provided > def messages (filters = {}); end > > # returns all labels > def labels; end > > # returns the label that has the name "name" > # as a Label object > def label (name); end > > # etc etc > end > > # a list of messages. should be sortable and searchable. > class MessageList; end > > # a single message > class Message > attr_reader :subject, :body, :to, :from, :date > > # applies a label to the message. > # can take either a string or a Label object as argument > def apply_label (label); end > > def remove_label; end > > def archive; end > > def unarchive; end > > def archived?; end > > def mark_read; end > > def mark_unread; end > > def read?; end > > def report_spam; end > > def report_not_spam; end > > def spam?; end > > def trash; end > > def untrash; end > > # etc etc > end > > class Label > # you get the picture > end > > def connect (*args, &block) > Connection.new(*args, &block) > end >end > >GMailer::connect(username, password) do |gmail| > gmail.messages(:unread).each do |msg| > puts "subject: " + msg.subject > puts "from: " + msg.from > end >end > Thanks for suggestions. I will try to satisfy you in the next release.:) In the mean time, you can use this for fetching each message content: g.messages(:standard=>'all').each {|m| puts "ID: #{m['id']} Subject: #{m['subject']} / Snippet: #{m['snippet']}" g.fetch(:conversation=>m['id']).conv.each {|c| puts "From: #{c['sender']} #{c['sender_email']}" puts "Subject: #{c['subject']}" puts "Full Message Body: #{c['body']}" } } Regards, Park Heesob