Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3407770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:47:31+00:00 2026-05-18T05:47:31+00:00

If I have a mail object, eg: mail = Mail.new do from jim@gmail.com to

  • 0

If I have a mail object, eg:

mail = Mail.new do
  from      "jim@gmail.com"
  to        "jane@yahoo.com"
  subject   "Example"
  text_part do
    body    "Blarg"
  end
  add_file  "/some/file/or/some_such.jpg"
end

If I were to receive the above mail in my application

received_mail = mail.encoded
Message.parse(received_mail)

How would I pass the attachment on to CarrierWave/Paperclip (not fussed about which, I’ll use whichever one handles this best)? I’ve tried a few different methods, but I keep running in to various stumbling blocks – has anyone got a working solution for it?

My current attempt is:

mail.attachments.each do |attachment|
  self.attachments << Attachment.new(:file => Tempfile.new(attachment.filename) {|f| f.write(attachment.decoded)})
end

This doesn’t appear to work – any tips?
end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:47:31+00:00Added an answer on May 18, 2026 at 5:47 am

    I know that when I tried to take mail attachments and use them with paperclip, I also ran into some problems. The problem as I remember it was that paperclip expected certain attributes on the File object passed to it.

    I solved it like this:

    mail.attachments.each do |attachment|
      file = StringIO.new(attachment.decoded)
      file.class.class_eval { attr_accessor :original_filename, :content_type }
      file.original_filename = attachment.filename
      file.content_type = attachment.mime_type
    
      #Then you attach it where you want it
      self.attachments << Attachment.new(:file => file)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have List object filled with instances of a custom struct. list.Add(new Mail(mail1, test11,
I have a little python script that pulls emails from a POP mail address
I have one interesting problem. I must parse mail body (regular expression), get some
I have found this example on StackOverflow: var people = new List<Person> { new
I have a service responsible for subscribing to EWS for new mail notification. I've
I get object from hibernate query. Then i have list of fields, whose getters
Is there some way to have the Mail Merge capability in my application? Maybe
I have an HTML Mail template, with a place holder for the image. I
I have a JLabel which has an e-mail address in it. I used HTML
I have noticed that some apps like Safari and Mail show a loading indicator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.