Saturday, October 02, 2004

Mail merge ruby script

The other day, I needed to send the gmail invite to all the folks in the development team and it amounted to more than 30 people. Since each one would have to be sent a different invite, distribution list won't work. Here is a quick Ruby script I cranked up to send the invites. Go ruby.


require 'net/smtp'

receiver_list = ['x@y.com','a@b.com']
invites_list = ['invite_url_1','invite_url_2']
smtp = Net::SMTP.start('mta1.mycompany.com', 25)
sender = 'me@gmail.com'

receiver_list.each_index {|email_index|
receiver = receiver_list[email_index]
invite_link = invites_list[email_index]
puts "Sending e-mail to " + receiver
msgstr = "From: Venkat <#{sender}>\n"
msgstr += "To: #{receiver} <#{receiver}>\n"
msgstr += "Subject: Gmail invitation\n"
msgstr += "I would like you to enjoy a small gift, a new Gmail account.\n"
msgstr += "#{invite_link}\n\n"
msgstr += "Cheers,\n"
msgstr += "Venkat.\n"
puts smtp.send_mail(msgstr, sender, receiver)
}

Can sequence diagrams be any more simpler?

For some of the work we have been doing recently, I wanted to sketch small sequence diagrams to explain the flow.

As always the temptation is to launch Rational Rose. This time I hadn't set it up in my new laptop as I didn't want to bloat it with lots of software. Since I had heard about ArgoUML, I tried that next. It was very quick to launch it as it was Webstart enabled. But the sequence digramming option itself wasn't enabled for some reason. Docs weren't of help.

As always the better ideas come last to me. With so little brain cells I have left it is wonder that they even come . About a year ago as I was playing with AspectWerkz, I had integrated it with Sequence. At that time, I was doing this to draw the sequence digram on the fly as the code executes. We will talk about that in another post. This tool is really cool. I should suggest this to be Webstart enabled also. It has a very simple text syntax where you specify the sequence steps and it draws the digram for you. How can you do faster than this? Here is some simple text sequence I wrote and the digram below.


SomeObject.someCall {
Connection.prepareStatement(sql) -> preparedStatement {
ScopingAspect.around(connection, sql) -> preparedStatement {
SqlStatement.parse(sql) -> statement;
LegacyScoper."getScopeBy EntityName + ViewName"() -> condition;
LegacyScoper.[isEmpty]getScopeByViewName() -> condition;
LegacyScoper.[isEmpty]getScopeByEntityName() -> condition;
LegacyScoper.[isEmpty]getScopeByTableName() -> condition;
DefaultScoper.[isEmpty]getScope() -> condition;
SqlStatement.[isNotEmpty]addCondition(condition);
SqlStatement.toSql() -> sql;
Connection.proceed(sql) -> preparedStatement;
}
}
}




Friday, October 01, 2004

Migrating from Yahoo Mail to Gmail

The Gmail service is quite impressive and I couldn't stop thinking about getting to use it on a regular basis as soon as I can.

So, I decided to copy all my Yahoo mails to Gmail. Here is how did it and the steps you need to follow:

Download mails to local drive

Since I have a paid Yahoo account (MailPlus), Yahoo allowed the e-mails to be downloaded locally. Those with free Yahoo accounts needn't go disappointed. There is YPops as well as FetchYahoo which can be used to download the mails to Thunderbird.

Convert mails to a standard format

In my case, unfortunately the files were all individual files with eml format. You may not have this issue if you downloaded directly to Thunderbird. eml2mbox script came to the rescue. How fortunate that we have scripting languages like Ruby where people can crank up something in minutes. Now I have the mails in the mbox format.

Upload mails to Gmail

Though Gmail doesn't have the upload support yet, Mark Lyon has written a nice Python script that loads e-mails in various formats like mbox and maildir to load e-mails to gmail. Thanks Mark Lyon. There was a small issue in which the emltombox.rb script didn't create the mbox file in the cleanest format. Mark Lyon anticipated this and given a switch in the utility to cater for such files. Mark's utility also takes care of properly marking the sent mails so that took care of sent mails folder also.

Mark Lyon's utility didn't run in my machine straightaway. It kept using the Tcl library in my ruby installation directory. After some digging, I turned off the TCL_LIBRARY environment setting (Windows) and the utility ran fine.

After loading the e-mails to Gmail, I tested to make sure that e-mail "conversations" were recognized by gmail. Surprisingly they weren't. The problem was that the mails I am loading were sent by my yahoo ids or pobox ids. So, I had to edit the mbox files to replace those previous ids with gmail e-mail id. I should suggest this to Mark to add it to his utility or do it myself. May be he did this step manually and forgot to mention in the web site.

Now that I have my old e-mails loaded up in gmail, I am forwarding mails to my pobox.com alais to the gmail mailbox also. I did the same with sneakemail. I still have a couple of more folders to import into gmail and that should be a breeze to do.

Now I will be checking my gmail id like once a day and send and receive mails.