Replies: 2 comments
-
I've added |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just in case anyone stumble upon this from google. s = msg.body.decoded
sc = StringScanner.new s
fail sc.peek(100).inspect unless sc.scan(/\n(----(--)?==?_[a-z].+)\n/i)
delimeter = sc[1]
h = {}
loop do
fail sc.peek(100).inspect unless sc.scan(/\n?Content-Type: text\/([a-z]+);\n charset=([A-Z0-9-]+)/)
fail if h[type = sc[1]]
charset = sc[2]
sc.skip_until /\n\n/
h[type] = Base64.decode64(sc.scan_until(Regexp.new delimeter)[0..-delimeter.size]).force_encoding(charset).encode("utf-8")
break if "--\n" == sc.peek(10)
end
fail unless %w{ plain html } == h.keys to then accidentally find that it is already returning exact same "plain" string from just msg.text_part.decoded i.e. it is the flaw of the "mail" gem docs that they mention only |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have to read the GMail via IMAP. I use the gem "mail" but it returns the mail message like this:
The only thing that might help me to decode the "format=flowed" I've found is https://www.rubydoc.info/gems/mime/0.4.0 with the class
MIME::ContentFormats::TextFlowed
P.S.: oh, anyway, while writing this post discovered this part of it ..(
UPD: maybe it's not about "flowed" but about some sort of multipart... haven't figure it out how to parse it yet.
Beta Was this translation helpful? Give feedback.
All reactions