how to remove previous replies from an email item

G

Gregor

Hi.

Emails are very often replies to previous emails. I'm writing add-in, where
I would need to get only the body text of the last email - I want to remove
the content from the previous emails.

Is there a way to do this? Is there any Outlook API that could help here?

As I noticed, MailItem.Body and MailItem.HtmlBody never contain the ">"
character which is typically inserted when replying to emails. I guess
Outlook filters this out. It's rather unfortunate since they could be very
successfully used to detect previous conversations.

Any help would be greatly appreciated!!
Gregor
 
K

Ken Slovak - [MVP - Outlook]

Conversations in Outlook are maintained and grouped by 2 properties:
ConversationTopic and ConversationIndex.

ConversationTopic is a normalized subject that ignores things like RE or
FWD.

ConversationIndex is started by the first item in a thread and consists of a
time/date stamp. Each succeeding item in the conversation has an additional
time/date stamp appended to it. So by matching the ConversationTopic of the
new reply you can find all the items in that folder that could be in that
conversation. If an item's ConversationIndex time/date stamp is 1 time/date
stamp shorter than the reply item's ConversationIndex value but otherwise is
equal to the ConversationIndex value you have found the previous item in the
thread.

Once you've found the previous item you can get the Body or HTMLBody and
that will let you remove any previously existing text you want to remove.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top