I need to parse email body(it can be both text and html), of forwarded email, to find original sender of email(both name and email).
So lets say that John send email to Steve, and Steve forward to Matt. So, in most clients message will look like:
From: John Smith [mailto:john@example.com]
Sent: 02 March 2012 AM 01:23
To: 'Steve'
Subject: Hello Steve
Or
---------- Forwarded message ----------
From: John Smith <ejohn@example.com>
Date: 02 March 2012 AM 01:23
Subject: Hello Steve
To: Steve <steve@example.com>
So, how can I extract from name and from email values in those two cases? Please note that I need to extract only first appearance of this text, because there can be multiple appearances of lines "From:...".