Search code examples
c#pop3

OpenPop.net, extract just last message from chain


I am using Openpop.net with c#. I can get the emails but want to extract the body text not the full email chain text. Is there a way of just getting the message body without the RE: parts? Thanks.


Solution

  • Unfortunately, there's no easy way to do what you want to do because the text body of an email is free-form text and each mail client can (and often does) use a different way of quoting the original message text that it is replying to.

    Usually, but not always, the older message(s) in the conversation will be rewritten to have a "> " sequence at the start of each line.

    If that is the case, you can filter those lines out to get the latest message text of the conversation.

    Keep in mind, however, that many people will do what is called "replying inline" where there interlace their responses with the quoted questions from a previous email. For example:

    Hi Joe,
    
    My answers are below.
    
    On Mon, Feb 8 2021, Joe Smith wrote:
    >
    > Jake,
    >
    > Have you sent in that TPS report yet?
    
    Nope, not yet. I was hoping to send it in today.
    
    > If not, I've got a few facts & figures that should probably be included.
    
    Sure, come by my desk after lunch and we'll work those details into my final report.
    
    - Jake