Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Deleting Duplicate Mailitems (http://www.outlookbanter.com/outlook-vba/25557-deleting-duplicate-mailitems.html)

Geoff August 30th 06 11:01 AM

Deleting Duplicate Mailitems
 
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




Ken Slovak - [MVP - Outlook] August 30th 06 03:54 PM

Deleting Duplicate Mailitems
 
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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





Geoff August 30th 06 09:27 PM

Deleting Duplicate Mailitems
 
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


"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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







Geoff October 15th 06 01:42 AM

Deleting Duplicate Mailitems
 
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 a

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


"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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




Ken Slovak - [MVP - Outlook] October 16th 06 07:29 PM

Deleting Duplicate Mailitems
 
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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 a

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



Geoff October 18th 06 05:15 PM

Deleting Duplicate Mailitems
 
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


"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm






Ken Slovak - [MVP - Outlook] October 19th 06 03:38 PM

Deleting Duplicate Mailitems
 
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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



Geoff October 19th 06 05:21 PM

Deleting Duplicate Mailitems
 
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

"Ken Slovak - [MVP - Outlook]" wrote in message
...
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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Geoff" wrote in message
...
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






All times are GMT +1. The time now is 08:53 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com