# \[ANN\] gmailer-0.0.5

**URL:** <https://rubytalk.org/t/ann-gmailer-0-0-5/20446>\
**Category:** ruby-talk\
**Created:** [28 August 2005 06:27 UTC](https://rubytalk.org/t/ann-gmailer-0-0-5/20446 "2005-08-28T06:27:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Park\_Heesob3](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@Park\_Heesob3](https://rubytalk.org/u/Park_Heesob3)\
**Post date:** [28 August 2005 06:27 UTC](https://rubytalk.org/t/ann-gmailer-0-0-5/20446/1 "2005-08-28T06:27:23Z")

</div>

GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone  
or send message with file attachments.

CHANGE since 0.0.4  
- add create\_label, delete\_label, rename\_label, apply\_label, delete\_label  
method  
- add update\_preference, get\_preference method  
- fix some bugs

The usage is very simple and compact like this:

GMailer.connect(name,pwd) do |g|  
&nbsp;&nbsp;#fetch  
&nbsp;&nbsp;g.fetch(:label=\>"my\_label") {|s|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts "Total # of conversations of my\_label = " + s.box\_total.to\_s  
&nbsp;&nbsp;}

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

&nbsp;&nbsp;#send  
&nbsp;&nbsp;g.send(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:to =\> "whoo@foo.bar",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:subject =\> "Hello There!",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:body =\> "Hi...\n\nBlah blah blah~...",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:files =\> ["./test.txt"]  
&nbsp;&nbsp;&nbsp;)

&nbsp;&nbsp;# update\_preference  
&nbsp;&nbsp;g.update\_preference(:max\_page\_size=\>50,  
&nbsp;&nbsp;&nbsp;&nbsp;:keyboard\_shortcuts=\>true,  
&nbsp;&nbsp;&nbsp;&nbsp;:indicators=\>true,  
&nbsp;&nbsp;&nbsp;&nbsp;:display\_language=\>'en',  
&nbsp;&nbsp;&nbsp;&nbsp;:signature=\>'This is a signature',  
&nbsp;&nbsp;&nbsp;&nbsp;:reply\_to=\>'return@foo.bar',  
&nbsp;&nbsp;&nbsp;&nbsp;:snippets=\>true,  
&nbsp;&nbsp;&nbsp;&nbsp;:display\_name=\>'Display Name')

&nbsp;&nbsp;# get preference  
&nbsp;&nbsp;pref = g.get\_preference  
&nbsp;&nbsp;puts "Display language:#{pref['display\_language']}, Max Page  
Size:#{pref['max\_page\_size']}"

&nbsp;&nbsp;#creating new labels  
&nbsp;&nbsp;g.create\_label('label\_name')

&nbsp;&nbsp;#renaming existing labels  
&nbsp;&nbsp;g.rename\_label('label\_name','renamed\_label')

&nbsp;&nbsp;#deleting labels  
&nbsp;&nbsp;g.delete\_label('label\_name')

&nbsp;&nbsp;#applying a label to a message  
&nbsp;&nbsp;g.apply\_label(msgid,'label\_name')

&nbsp;&nbsp;#removing a label from a message  
&nbsp;&nbsp;g.remove\_label(msgid,'label\_name')

&nbsp;&nbsp;# get labels  
&nbsp;&nbsp;labels = g.get\_labels

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

Project:: [http://rubyforge.org/projects/gmailutils/](http://rubyforge.org/projects/gmailutils/)  
Bugs:: [http://rubyforge.org/tracker/?group\_id=869](http://rubyforge.org/tracker/?group_id=869)

Regards,

Park Heesob

---

<div class="post-metadata">

**Author:** ![Daniel\_Amelang](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Daniel\_Amelang](https://rubytalk.org/u/Daniel_Amelang)\
**Post date:** [28 August 2005 08:50 UTC](https://rubytalk.org/t/ann-gmailer-0-0-5/20446/2 "2005-08-28T08:50:15Z")

</div>

Hey Park, looks great. We can tell that you're putting a lot into this  
lib. And aren't you supposed to be new to this ruby thing 🙂 You're  
doing great.

Minor note: you have a number of methods that have the name 'get\_this'  
and 'get\_that'. Consider leaving the 'get' out of the name. In other  
languages, get methods are common to distinguish methods from public  
members, but since everything is a method in ruby, people tend to  
leave out the 'get'. So, basically, you'd have g.messages instead of  
g.get\_messages and g.labels instead of g.get\_labels.

I put it on the tracker to make this suggestion 'official'.

Perhaps other people on this list can confirm/dispute that this would  
be preferred.

Dan
