[ANN] gmailer-0.0.8 released

P

Park Heesob

GMailer 0.0.8 Released
=======================

This is the 0.0.8 release of GMailer by Park Heesob.
This is a class library for interface to Google's webmail service.

What is GMailer?
-----------------

GMailer can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. It provides edit methods for labels,
preferece settings, starring and archiving message.


What's new in this release?
---------------------------

Rename is_connected method to connected?
Add support for the new feature 'Send mail as'. If you have multiple
verified
"Send mail as:" email addresses, you can choose one 'From:' email address.
Refer to http://gmail.google.com/support/bin/answer.py?answer=20616
Thanks Daniel Schierbeck and Michel Martens!

How to use GMailer?
-----------------------
Sample usage:

GMailer.connect(name,pwd) do |g|
#fetch
g.fetch:)label=>"my_label") {|s|
puts "Total # of conversations of my_label = " + s.box_total.to_s
}

#get contact
g.fetch:)contact=>"freq").each do |item|
puts "Name: #{item['name']} Email: #{item['email']}"
end

#send message
# 'From' default gmail.com account
g.send(
:to => "(e-mail address removed), my_friend@his_company.com, (e-mail address removed)"
:cc => "(e-mail address removed)"
:subject => "Hello There!",
:body => "Hi...\n\nBlah blah blah~~...",
:files => ["./my_pic.jpg", "./my_cv.txt"])

# multiple verified email addresses and choose one 'From:' email address
g.send(
:from => "(e-mail address removed)",
:to => "(e-mail address removed), my_friend@his_company.com, (e-mail address removed)"
:cc => "(e-mail address removed)"
:subject => "Hello There!",
:body => "Hi...\n\nBlah blah blah~~...",
:files => ["./my_pic.jpg", "./my_cv.txt"])

# update_preference
g.update_preference:)max_page_size=>50,
:keyboard_shortcuts=>true,
:indicators=>true,
:display_language=>'en',
:signature=>'This is a signature',
:reply_to=>'(e-mail address removed)',
:snippets=>true,
:display_name=>'Display Name')

# get preference
pref = g.preference
puts "Display language:#{pref['display_language']}, Max Page
Size:#{pref['max_page_size']}"

#creating new labels
g.create_label('label_name')

#renaming existing labels
g.rename_label('label_name','renamed_label')

#deleting labels
g.delete_label('label_name')

#applying a label to a message
g.apply_label(msgid,'label_name')

#removing a label from a message
g.remove_label(msgid,'label_name')

#apply star to a message
g.apply_star(msgid)

#remove star from a message
g.remove_star(msgid)

#archive a message
g.archive(msgid)

#unarchive a message
g.unarchive(msgid)

#mark a message as read
g.mark_read(msgid)

#mark a message as unread
g.mark_unread(msgid)

#report a message as not spam
g.report_spam(msgid)

#report a message as not spam
g.not_spam(msgid)

#move a message to trash
g.trash_in(msgid)

#move a message from trash to inbox
g.trash_out(msgid)

#delete a trash message forever
g.delete_trash(msgid)

#delete a spam message forever
g.delete_spam(msgid)

#get labels
labels = g.labels

#get messages
g.messages:)label=>labels[0]).each {|m|
puts "Subject: #{m['subject']} / Snippet: #{m['snippet']}" if m['new?']
}

#get inbox messages
g.messages:)standard=>'inbox').each {|m|
puts "Subject: #{m['subject']} / Snippet: #{m['snippet']}" if m['new?']
}

end


Project:: http://rubyforge.org/projects/gmailutils/
Bugs:: http://rubyforge.org/tracker/?group_id=869
Document:: http://rubyforge.org/docman/?group_id=869
Download:: http://rubyforge.org/frs/?group_id=869

How do I get GMailer?
----------------------

If you have RubyGems installed:

$ sudo gem install gmailer # in *NIX
gem install gmailer # in Windows

Or not, download the latest release from
http://rubyforge.org/frs/?group_id=869
and run install.rb



Cheers,

Park Heesob
 
D

Daniel Schierbeck

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
 
D

David Teare

Thanks for sharing this as a GEM.

I am having some troubles getting it to work. I installed gmailer
v0.8 but I can't figure out how to "require" it. Am I missing
something obvious?

$ gem list | grep gmail
gmailer (0.0.8)
$ ruby --version
ruby 1.8.2 (2004-12-25) [powerpc-darwin7.8.0]
$ gem --version
0.8.10

$ irb
irb(main):001:0> require "GMail"
LoadError: No such file to load -- GMail
from (irb):1:in `require'
from (irb):1
irb(main):002:0> require "GMailer"
LoadError: No such file to load -- GMailer
from (irb):2:in `require'
from (irb):2
irb(main):003:0> require "gmailer"
LoadError: No such file to load -- gmailer
from (irb):3:in `require'
from (irb):3


GMailer 0.0.8 Released
=======================

This is the 0.0.8 release of GMailer by Park Heesob.
This is a class library for interface to Google's webmail service.

What is GMailer?
-----------------

GMailer can fetch mails, save attachements, get cotact lists,
invite someone
or send message with file attachments. It provides edit methods for
labels,
preferece settings, starring and archiving message.


What's new in this release?
---------------------------

Rename is_connected method to connected?
Add support for the new feature 'Send mail as'. If you have multiple
verified
"Send mail as:" email addresses, you can choose one 'From:' email
address.
Refer to http://gmail.google.com/support/bin/answer.py?answer=20616
Thanks Daniel Schierbeck and Michel Martens!

How to use GMailer?
-----------------------
Sample usage:

GMailer.connect(name,pwd) do |g|
#fetch
g.fetch:)label=>"my_label") {|s|
puts "Total # of conversations of my_label = " +
s.box_total.to_s
}

#get contact
g.fetch:)contact=>"freq").each do |item|
puts "Name: #{item['name']} Email: #{item['email']}"
end

#send message
# 'From' default gmail.com account
g.send(
:to => "(e-mail address removed), my_friend@his_company.com, (e-mail address removed)"
:cc => "(e-mail address removed)"
:subject => "Hello There!",
:body => "Hi...\n\nBlah blah blah~~...",
:files => ["./my_pic.jpg", "./my_cv.txt"])

# multiple verified email addresses and choose one 'From:' email
address
g.send(
:from => "(e-mail address removed)",
:to => "(e-mail address removed), my_friend@his_company.com, (e-mail address removed)"
:cc => "(e-mail address removed)"
:subject => "Hello There!",
:body => "Hi...\n\nBlah blah blah~~...",
:files => ["./my_pic.jpg", "./my_cv.txt"])

# update_preference
g.update_preference:)max_page_size=>50,
:keyboard_shortcuts=>true,
:indicators=>true,
:display_language=>'en',
:signature=>'This is a signature',
:reply_to=>'(e-mail address removed)',
:snippets=>true,
:display_name=>'Display Name')

# get preference
pref = g.preference
puts "Display language:#{pref['display_language']}, Max Page
Size:#{pref['max_page_size']}"

#creating new labels
g.create_label('label_name')

#renaming existing labels
g.rename_label('label_name','renamed_label')

#deleting labels
g.delete_label('label_name')

#applying a label to a message
g.apply_label(msgid,'label_name')

#removing a label from a message
g.remove_label(msgid,'label_name')

#apply star to a message
g.apply_star(msgid)

#remove star from a message
g.remove_star(msgid)

#archive a message
g.archive(msgid)

#unarchive a message
g.unarchive(msgid)

#mark a message as read
g.mark_read(msgid)

#mark a message as unread
g.mark_unread(msgid)

#report a message as not spam
g.report_spam(msgid)

#report a message as not spam
g.not_spam(msgid)

#move a message to trash
g.trash_in(msgid)

#move a message from trash to inbox
g.trash_out(msgid)

#delete a trash message forever
g.delete_trash(msgid)

#delete a spam message forever
g.delete_spam(msgid)

#get labels
labels = g.labels

#get messages
g.messages:)label=>labels[0]).each {|m|
puts "Subject: #{m['subject']} / Snippet: #{m['snippet']}" if m
['new?']
}

#get inbox messages
g.messages:)standard=>'inbox').each {|m|
puts "Subject: #{m['subject']} / Snippet: #{m['snippet']}" if m
['new?']
}

end


Project:: http://rubyforge.org/projects/gmailutils/
Bugs:: http://rubyforge.org/tracker/?group_id=869
Document:: http://rubyforge.org/docman/?group_id=869
Download:: http://rubyforge.org/frs/?group_id=869

How do I get GMailer?
----------------------

If you have RubyGems installed:

$ sudo gem install gmailer # in *NIX

gem install gmailer # in Windows

Or not, download the latest release from
http://rubyforge.org/frs/?group_id=869
and run install.rb



Cheers,

Park Heesob
 
D

David Teare

--Apple-Mail-3--714695063
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed

+1 for this feature. Can we see it in version 0.0.9? ;)

GMailer::connect(username, password) do |gmail|
gmail.messages:)unread).each do |msg|
puts "subject: " + msg.subject
puts "from: " + msg.from
end


--Apple-Mail-3--714695063--
 
M

Mark Hubbart

Thanks for sharing this as a GEM.
=20
I am having some troubles getting it to work. I installed gmailer
v0.8 but I can't figure out how to "require" it. Am I missing
something obvious?
=20
$ gem list | grep gmail
gmailer (0.0.8)
$ ruby --version
ruby 1.8.2 (2004-12-25) [powerpc-darwin7.8.0]
$ gem --version
0.8.10
=20
$ irb
irb(main):001:0> require "GMail"
LoadError: No such file to load -- GMail
from (irb):1:in `require'
from (irb):1
irb(main):002:0> require "GMailer"
LoadError: No such file to load -- GMailer
from (irb):2:in `require'
from (irb):2
irb(main):003:0> require "gmailer"
LoadError: No such file to load -- gmailer
from (irb):3:in `require'
from (irb):3

perhaps try:
cheers,
Mark
 
D

David Teare

The require_gem seemed to work (it returned true), but I still had
the error below. No worries though, I just downloaded the rb code
and included it directly - it works great now!

NameError: uninitialized constant GMailer
from (irb):9


Thanks for sharing this as a GEM.

I am having some troubles getting it to work. I installed gmailer
v0.8 but I can't figure out how to "require" it. Am I missing
something obvious?

$ gem list | grep gmail
gmailer (0.0.8)
$ ruby --version
ruby 1.8.2 (2004-12-25) [powerpc-darwin7.8.0]
$ gem --version
0.8.10

$ irb
irb(main):001:0> require "GMail"
LoadError: No such file to load -- GMail
from (irb):1:in `require'
from (irb):1
irb(main):002:0> require "GMailer"
LoadError: No such file to load -- GMailer
from (irb):2:in `require'
from (irb):2
irb(main):003:0> require "gmailer"
LoadError: No such file to load -- gmailer
from (irb):3:in `require'
from (irb):3

perhaps try:

cheers,
Mark
 
P

Park Heesob

Hi,

From: Daniel Schierbeck <[email protected]>
Reply-To: (e-mail address removed)
To: (e-mail address removed) (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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] gmailer-0.0.7 2
[ANN] gmailer 0.0.9 2
[ANN] gmailer-0.0.5 0
[ANN] gmailer 0.1.0 3
[ANN] gmailer 0.0.1 (plain text) 5
[ANN] gmailer 0.0.3 3
Problems with gmailer 2
[ANN] gmailer-0.0.2 2

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top