Detect end of new message in email conversation body

后端 未结 3 509
粉色の甜心
粉色の甜心 2020-12-20 21:40

When a message gets replied or forwared the previous thread gets appended on your new mail by placing i.e. ----Original Message---- in front of it.

Outlook does the

3条回答
  •  独厮守ぢ
    2020-12-20 22:20

    The answer depends on whether the user is sending HTML or rich text email. (This will usually depend on whether they are replying to/forwarding a message in HTML or RTF, unless they manually change the format.)

    In either case, you need to look for a pattern that indicates the end of the message you are interested in, and stop there. Use Instr() to identify where you need to stop. Then, as you are parsing the text looking for your "certain words", keep track of how many characters you have read and stop when you get to the marker.

    Rich text

    Look in Item.Body for "^p^p__________________________ ^p".

    That's 2 instances of VbCrLf, 46 instances of Chr(95), a space, and then another instance of VbCrLf.

    HTML

    In Item.Body, the token is "^p  _  ^p".

    That's one VbCrLf, 2 spaces, 5 instances of Chr(95), 2 more spaces, and another VbCrLf.

    In Item.HTMLBody, the token is


    That token has a VbCrLf before it, between the two lines, and at the end.

提交回复
热议问题