I need to open an email message and parse that message (headers and body) for all email addresses. Does anyone have an easy way of doing this?
I've not decided which way would be best, but I could read a line at a time (but the address might be split on multi-lines if in the body. I've thought of reading a message at a time using the " From " into an string and then searching for the @, but that is highly clumsy. Not to mention that I now have to seek forward and backward from there. I've thought about greping the file first and getting the lines that have an address but I'm still stuck with removing the possible misc chars before and after.
I'm hoping it's obvious that in the headers there are many different characters that can suround an address, such as <user@domain.com>... and "Name <user@domain.other.no.here> and "user@domain" and not all of them have <> either. Nothing seems very standardized here, not even white space.
Thanks all
John