GithubHelp home page GithubHelp logo

Parsing Multipart bodies about mms2r HOT 3 CLOSED

monde avatar monde commented on July 19, 2024
Parsing Multipart bodies

from mms2r.

Comments (3)

monde avatar monde commented on July 19, 2024

The @media is a hash of arrays keyed by content/mime type. so @media['text/html'] returns an array of file paths that are of that time. You can enumerate over that array and open each file and process them as you see fit. See the #default_media and #attachment methods for examples of this strategy. Their implementation is what I described and they choose the file that is the largest in size. Post a comment if you get it to work in the way you require and I'll close this out.

from mms2r.

Hyped avatar Hyped commented on July 19, 2024

This is what I ended up doing. I know the code isnt very sexy but it works at the moment.
if ( mms.multipart? && mms.media.has_key?("text/html"))
file = File.open("#{mms.media['text/html']}")
while content = file.gets
body = body + content
end
file.close
else
body = mms.body
body.gsub!("\n\r", "
")
body.gsub!("\n", "
")
end

from mms2r.

monde avatar monde commented on July 19, 2024

it seems like

file = File.open("#{mms.media['text/html']}")

should at least be
file = File.open("#{mms.media['text/html'].first}")

you should probably enumerate over mms.media['text/html'] that will be an array of filepaths.

from mms2r.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.