I have been given the task of creating an interactive timeline. I need to be able to click an element that opens a nicely styled preview of an email message. Currently, I can’t find any easy way to consistently grab the various field values (like To: From:, etc)
Has anyone come up with a way to isolate the various field values in an html email message so that they can be styled using CSS ?
I will submit examples if this doesn’t make sense. Thanks for any replies.
This is an email. Do you need to do this via JS? Is it possible, for example, to parse the email server-side and send JSON to the browser? That would be the simplest, most robust approach.
Do you need to be able to handle multi-part emails? If not, you might be able to split the email into header / body (split on the blank line), and then split the header into individual lines (split on newline) so you can read each name:value (split on colon).
Displaying the body as HTML is risky, since it would allow for code injection. Not sure how to approach that from the client side.
All this is fairly complex, though. There are server-side tools and libraries that could handle it much easier, and much more reliably. Plus, it would be a small fraction of the work.