Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error saving attachment #28

Closed
cas27 opened this issue Aug 12, 2010 · 8 comments
Closed

Error saving attachment #28

cas27 opened this issue Aug 12, 2010 · 8 comments

Comments

@cas27
Copy link

cas27 commented Aug 12, 2010

Here is my code

  vmFolder = '/home/user/vm/'
  email = gmail.inbox.emails(:unread).first
  email.attachments[0].save_to_file(vmFolder)

Getting this error

/var/lib/gems/1.8/gems/mail-2.2.5/lib/mail/message.rb:1251:in `method_missing':
undefined method `save_to_file' for #<Mail::Part:0xb74e9c1c> (NoMethodError)
@ButuzGOL
Copy link

ButuzGOL commented Oct 9, 2010

I have the same problem (

@stefanobernardi
Copy link

Has anyone solved this?

@cas27
Copy link
Author

cas27 commented Dec 31, 2010

Yeah here is how I got it to work

File.open(saveLocation,"w+") { |local_file| local_file << email.attachments.first.decoded }

@stefanobernardi
Copy link

Yup I got it too with
email.attachments.each do |a|
file = File.new("attachments/" + a.filename, "w+")
file << a.decoded
file.close
# do your stuff here
File.delete("attachments/" + a.filename) #just in case
end

@stefanobernardi
Copy link

Thanks for the quick reply anyways!

@stefanwille
Copy link

I think the cause here is that both the 'mail' gem and 'ruby-gmail' define a class Mail::Part, and the former gem wins the naming conflict.

@macedo
Copy link

macedo commented Jan 19, 2012

This works for me too! ;)

@myobie
Copy link
Collaborator

myobie commented Dec 19, 2012

Sorry, this was a mistake in the readme, the mail gem doesn't offer that method.

@myobie myobie closed this as completed Dec 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants