Deleting Duplicate Mailitems

G

Geoff

Which Mailitem property stores the fact that a received Mailitem has been
replied to?

I need to distinguish programatically between duplicate Mailitems:

1. Some mailitems show "You replied on ... Click here to find all related
messages".
2. Duplicate mailitems in the same folder are exactly the same except
they do not show the above message.

I have written a VBA program that scans thousands of emails in multiple
stores and folders. The program finds duplicate Mailitems in the same folder
(by comparing SenderName, To, ReceivedTime, SentOn, Subject and
Attachments.Count). I want to delete the duplicates that don't show the "You
replied on..." message. I hope there's a property that stores this "replied"
information. Does it exist? Is there a way to distinguish?

TIA
Geoff
 
K

Ken Slovak - [MVP - Outlook]

The property you're looking for isn't exposed in the Outlook object model.
It's in PR_LAST_VERB_EXECUTED (0x10810003), where replied to is 102. You'd
need to be using CDO 1.21 or Extended MAPI or a MAPI wrapper such as
Redemption (www.dimastr.com/redemption) to get at it.
 
G

Geoff

Hi Ken,

Many thanks. I'll give it a go tomorrow. I have CDO and Redemption
installed.

Thanks too for your previous help and book recommendations. Sorry I didn't
reply. In fact, I drafted a reply (ie some thoughts on Automation etc), but
thought twice before posting. I'm not sure comments (from my limited
perspective) are necessarily welcome to a more-knowledgeable wider audience.
I'll give it some more thought and maybe pluck up courage!

Thanks again.
Regards
Geoff
 
G

Geoff

Hi Ken,

I'm making great progress thanks to your earlier help!

I have a couple of more questions, if I may.

Using VBA and CDO 1.21 in Outlook, I'm sending a MAPI.Fields collection for
an Outlook Mailitem to a function containing the following code:

Dim lngValue as Long
lngValue = &H10810003
Set objOneField = objMAPIFieldsColl.item(lngValue)

As you mentioned, if the Mailitem has been replied to, then
objOneField.Value is 102.

If the Mailitem has not been replied to, the last code line above generates
a run-time error.

My questions are:

1. Am I right in assuming that the run-time error occurs because, when a
Mailitem has not been replied to, the field in question simply does not
exist? Can I trap the error and assume that the Mailitem has not been
replied to?

2. If a run-time error is not generated, I then get access to the field.
Do I have to ensure that its Value property is 102 before I can assume that
the Mailitem has been replied to? I'm wondering if the Value property could
contain other values that would mean other things.

Very many thanks for getting me this far.
Regards
Geoff
 
K

Ken Slovak - [MVP - Outlook]

You can check for IsEmpty() for fields that may not be there by default.

There are other verbs that could be there in the field, such as
EXCHIVERB_REPLYTOALL or EXCHIVERB_FORWARD , so check for a value of 102.

EXCHIVERB_REPLYTOALL (103) is set if ReplyToAll was used last,
EXCHIVERB_FORWARD (104) is set if Forward was used last.

The value will change as different actions are taken. If an item was replied
to the field value would be 102. If then you forwarded the same item it
would change to 104. The field only captures the last action taken.
 
G

Geoff

Hi Ken,

Very many thanks.
The field only captures the last action taken.

It was important for me to know that to solve my present problem. Thanks for
that.
You can check for IsEmpty() for fields that may not be there by default.

Where am I going wrong please?

When the PR_LAST_VERB_EXECUTED property does not exist (in the MAPI fields
collection for an Outlook Mailitem), the following code line produces a
run-time error (not as I expected FALSE):

"If IsEmpty(objMAPIFields.item(&H10810003)) Then"

But if I precede the above code line with:

"On Error Resume Next"

then the IsEmpty() function returns TRUE.

How did you mean I should use IsEmpty() please and what's going on above?

Just FMI, where would the following detailed information be stored:
"You replied on 15/10/2006 01:52. Click here to find all related messages."

TIA, Regards
Geoff
 
K

Ken Slovak - [MVP - Outlook]

Use the On Error Resume Next before testing for IsEmpty.

ConversationIndex and ConversationTopic. All items in a thread have the same
ConversationTopic and each one gets a Windows time struct of 8 bytes
appended to the previous ConversationIndex.
 
G

Geoff

Very many thanks.
I see - neat.
I think I'm nearly home and dry.
Where would we be without people like you?
Quite lost!
I'm very grateful.
Regards
Geoff
 

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