Comments (3)
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.
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.
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)
- Issue reading from /tmp directory in build environment HOT 9
- Sprint UndefinedConversionError with ruby 1.9.2 HOT 1
- UTF-8 error with yahoo email HOT 1
- Certain characters in Outlook HTML emails are getting garbled. HOT 2
- deprecation warning on ruby 1.9.3 HOT 8
- Correct Handling of   in media['text/plain'] HOT 4
- MMS2R::Media filename? should strip HOT 2
- Verizon text messages aren't parsing properly HOT 5
- Sprint Messages aren't parsing HOT 2
- not mail gem compatible HOT 2
- undefined method `return_path' for #<TMail::Mail... HOT 4
- Problems with ruby 1.9.2 and rails3 HOT 4
- Mail/MMS2R HOT 3
- default_media is nil HOT 12
- mms2r 2.4.1/ Tmail and application/octet-stream HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mms2r.