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

  • Home
  • SEARCH
  • 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

this code checks if i have mail from gmail, then sends m over serial
I have List object filled with instances of a custom struct. list.Add(new Mail(mail1, test11,
I have a service responsible for subscribing to EWS for new mail notification. I've
I have mail server configuration data (server - user name - password - port)
I have this mail script I have to run a few times. To start
I have a mail webform where I have to show the user only (-1)
I have implemented mail composer. But it opens mail composer whenever user had implemented
Is there some way to have the Mail Merge capability in my application? Maybe
As part of the registration process on a website, I have added mail confirmation.
I have a reminder mail sent to those who do not log on to

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.