Tuesday, July 1, 2008

Contact List importer in rails

Well I have been hearing this question a lot..Every one wants to market about their site directly from their place..So for that these days people are integrating 3rd party services where they can import contact lists from various address books such as gmail, yahoo, aol and so on...So I integrated plaxo which rails inorder to get this functionality in my site..

Here we go

First of all load these js in views


http://www.plaxo.com/css/m/js/util.js
http://www.plaxo.com/css/m/js/basic.js
http://www.plaxo.com/css/m/js/abc_launcher.js


this will help u to open the plaxo page where u will be able to nter the login details of your desired mail account and then import all the email list

This is the controller code which u need to write for calling the send mail option

def sendemail
@emails = params[:recipients].split(',')
for email in @emails
@send = Emailer.deliver_allcontacts(email,"", "Just Test", "Dont Worry its just an testing email")
end
flash[:notice] = "Mails are successfully sent"
redirect_to :action => 'invite'
end


finally the model

def allcontacts(to,from,subject,message)
@tomail = to
@from = from
@subject = subject
@body["message"] = message
end

this will send mail to all the contacts in the list..

Thats it..Now do marketing directly from ur website..

Dhaval Parikh
Software Engineer
Ruby on Rails
http://www.dhavalparikh.co.in

No comments: