2 Replies Latest reply: Nov 8, 2012 4:40 AM by 973009 RSS

    Split received message and cut RE part off

    973009
      Hey everybody,

      my little mail application is running! Yeah! JavaMail is great and I can receive/send emails easily. But I have still a two questions.

      1.When I parse the text of a responded email, I have all the text including the text I first wrote. You can imagine that a conversation with 10 REs in the Subject contains many lines but only the e.g. first 3 lines are important.
      Is there a smart way to recognize the old attached text?
      2. I have often emails with only a "text/html" part. I want to strip the <Tags> and get the plain text, but with the \n instead of <br> and <p>.
      How do you do this?

      best regards
      Alex
        • 1. Re: Split received message and cut RE part off
          Bill Shannon-Oracle
          1. There's no formally defined way to do this. There are some conventions that many
          email clients follow, and you can write some heuristic code that tries to recognize use
          of those conventions.

          2. Depends on how good a job you want to do. :-) If you just care about the simple cases
          it's not too hard to write a scanner/parser that recognizes the tags and removes them or
          replaces them. If you actually want to interpret the tags and format the plain text in some
          similar way, that's more work. Doing a really good job is very difficult, and you'll probably
          want to find some existing library that will parse html and render it as plain text.
          • 2. Re: Split received message and cut RE part off
            973009
            Thanks bshannon.
            So I have to get a lot of coffee and hit the keyboard ;-)