require 'rubygems'
require 'gmail'
gmail = Gmail.new('xxxxx', 'xxxxx') do |g|
unread_count=g.inbox.count(:unread)
print "There are " + g.inbox.count.to_s + " emails (" + unread_count.to_s + " unread).\n"
counter=1
g.inbox.emails(:unread).each do |msg|
print "#{counter}/#{msg.message.from}/#{msg.message.subject}/#{msg.message.attachments.length.to_s} attachment(s)\n"
msg.message.save_attachments_to("/home/mmcgrath/mail-puller/output")
counter+=1
end
end
There are four unread messages in the Inbox, three of which have attachments -- the script sees them correctly (i.e. Subject, From etc) but in all cases the attachments array is empty. Any thoughts?