How do I use the Mail gem for Ruby to extract the original message HTML content/text content from a forwarded email?
So far all the examples I see are related to extracting content from replies (not forwards), which is made a lot easier because you can just key in on --reply above this line--
in the message.
But in my case, I’m having people forward me confirmation emails, such as how TripIt parses flight itineraries from many different airline emails.
The problem is there is a complex hierarchy of “parts”, as well as parts containing other parts, and I am trying to come up with a foolproof way to find the original HTML source so I can parse it, and extract information from a forwarded email raw source.
m = Mail.read('raw.txt')
m.parts
m.parts.first.parts
m.parts.last.parts.first.parts # never ending....