dcparker / ruby-gmail

A Rubyesque interface to Gmail. Connect to Gmail via IMAP and manipulate emails and labels. Send email with your Gmail account via SMTP. Includes full support for parsing and generating MIME messages.
http://dcparker.github.com/ruby-gmail
792 stars 123 forks source link

Not seeing attachments #8

Closed mmcgrath closed 14 years ago

mmcgrath commented 14 years ago

Hi -- great work so far -- but I can't see attachments -- here's my program:

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?

mmcgrath commented 14 years ago

FYI -- I downloaded TMail (http://tmail.rubyforge.org/) -- it correctly parses the mime parts from the Gmail::Message.body

dcparker commented 14 years ago

Clever work with the TMail idea there. Bonus points for putting two and two together.

Just yesterday I've updated something that may have affected this and released version 0.0.6. Have you given that a try?

If that still doesn't work, are any of those emails safe to share with me? I'd be willing to inspect the MIME parts and find out what is causing the parsing to fail, if it is still failing.

mmcgrath commented 14 years ago

Hi -- I am using 0.0.6 -- I will email you one of the emails that's causing difficulty. Happy Christmas.

dcparker commented 14 years ago

Released 0.0.7 with a few code tweaks that should fix the problem.

thekindofme commented 14 years ago

Still have the same problem with 0.0.7

dcparker commented 14 years ago

thekindofme - would you be able to send me a copy of the "Original Message" from gmail's drop-down menu on the right? I don't want sensitive information of course, but just to look at the encoding and where the gem might be parsing incorrectly.