Yes, PR_CONVERSATION_INDEX is lost on external e-mails. You coudl in theory extract In-Reply-To headers from the extrenal messages, but that does not work too well...
Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "McKilty" <bluesbrthr@gmail.com> wrote in message news:d523bb8b-a693-4486-a080-a83287c6cc8c@f10g2000vbl.googlegroups.com... Not so much rebuild the tree, but I think I'd have to see the tree and then grab all the final messages... or the "leaf" of each conversation.
I used ConversationIndex and I was able to get it to work for the most part, but it seems like some external e-mails have the Conversation Index reset. I'm going to assume from your inquiry that POP3/SMTP reset the index. Is there anyway to handle these? Here is my code: Public Sub LeafCollector() Dim lConIndex As String Dim lMailItem As Long Dim lMailItem2 As Long Dim bDontSave As Boolean Dim myOutlook As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim oItems2 As Outlook.Items Set myOutlook = Outlook.Application Set myNameSpace = myOutlook.GetNamespace("MAPI") If myOutlook.ActiveExplorer.CurrentFolder.DefaultMessageClass <> "IPM.Note" Then MsgBox "This macro can only be run on e-mail folders." Else Select Case UCase(myOutlook.ActiveExplorer.CurrentFolder.Name) Case "INBOX CHRON", "SENT ITEMS" 'Do not allow it to be run on these folders MsgBox "Running this on Inbox Chron or Sent Items will tie up this machine for a long time. Outlook cannot be used while this is running. If you need to run this on this folder, please contact Rick Bray to make a qhick code change to allow this." Set myNameSpace = Nothing Set myOutlook = Nothing Exit Sub Case Else If MsgBox("There are " & myOutlook.ActiveExplorer.CurrentFolder.Items.Count & " items in this folder. Are you sure you want to run this on '" & myOutlook.ActiveExplorer.CurrentFolder.Name & "' ?", vbExclamation + vbYesNo, "Non-Sanctioned Outlook Folder") = vbNo Then Set myNameSpace = Nothing Set myOutlook = Nothing Exit Sub Else Set oItems2 = myOutlook.ActiveExplorer.CurrentFolder.Items End If End Select End If If Outlook.ActiveExplorer.Selection.Count > 0 Then For lMailItem = 1 To myOutlook.ActiveExplorer.CurrentFolder.Items.Count 'Loop through every e-mail Set myMailItem = myOutlook.ActiveExplorer.CurrentFolder.Items (lMailItem) bDontSave = False lConIndex = myMailItem.ConversationIndex For lMailItem2 = 1 To oItems2.Count 'Compare e-mail against every other e-mail until match is found If lMailItem <> lMailItem2 Then If oItems2(lMailItem2).ConversationIndex <> lConIndex Then If Left(oItems2(lMailItem2).ConversationIndex, Len(lConIndex)) = lConIndex Then bDontSave = True Exit For End If End If End If Next If myMailItem.UserProperties("SAVE") Is Nothing Then myMailItem.UserProperties.Add "SAVE", olText, True End If If bDontSave = False Then 'Label as KEEP so it is not removed. myMailItem.UserProperties("SAVE") = "KEEP" Else 'Label with folder name, so we can replace if it was removed in error. myMailItem.UserProperties("SAVE") = myOutlook.ActiveExplorer.CurrentFolder.Name End If myMailItem.Save Next For lMailItem2 = oItems2.Count To 1 Step -1 'Delete any e-mail that is not labeled as KEEP If oItems2(lMailItem2).UserProperties("SAVE") <> "KEEP" Then oItems2(lMailItem2).Delete End If Next lMailItem2 End If End Sub On Nov 22, 1:08 pm, "Dmitry Streblechenko" <dmi...@dimastr.com> wrote:
> So are you trying to rebuild the tree? > Are the message being sent between Exchange mailboxes or do they go > through > POP3/SMTP? > > -- > Dmitry Streblechenko (MVP)http://www.dimastr.com/ > OutlookSpy - Outlook, CDO > and MAPI Developer Tool > -"McKilty" <bluesbr...@gmail.com> wrote in message > > news:bb96e094-2e29-4946-a292-3c1a77f6b214@k19g2000yqc.googlegroups.com... >
> > This is a task I have that I really don't have a clue how to handle. > > My boss has a folder of e-mails and he just wants to keep the last e- > > mail from the conversation. Sounds easy enough, just filter on the > > conversation and sort by date. I could run some code to delete all > > but the last one.
>
> > However, sometimes a thread branches out into multiple threads, but > > the conversation stays the same. He may send an e-mail to three > > people and then hold conversations with each person. Those threads > > could even break into different conversations with other people, but I > > believe the conversation field would stay the same.
>
> > I'm picturing the a tree, where the trunk is the conversation, but > > each branch breaks off into more branches and maybe the final e-mail > > is the leaf. I need something that collects all the leaves-- I need a > > leaf catcher.
>
> > Is there a way to do this?
19 Nov 2009E-mail Conversation Tracking.McKilty
22 Nov 2009\ Re: E-mail Conversation Tracking.Dmitry Streblechenko
24 Nov 2009   \ Re: E-mail Conversation Tracking.McKilty
29 Nov 2009      \ Re: E-mail Conversation Tracking.Dmitry Streblechenko
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)