How can I modify conversationTopic so emails with different subjects are put in the same thread?

后端 未结 4 820
走了就别回头了
走了就别回头了 2020-12-10 16:26

I want to help Outlook 2010 thread my emails. My understanding is that it bases the conversation view off of the conversationTopic property of the MailIte

4条回答
  •  庸人自扰
    2020-12-10 17:26

    Here's a variation on @JoeFletch's script with some performance optimizations, something to keep it from freezing outlook, and optional additional macros for running it on all selected emails, and for running it when each new mail arrives.

    Option Explicit
    
    ' This requires: http://www.dimastr.com/redemption/download.htm
    Const ConversationIndexField As String = "http://schemas.microsoft.com/mapi/proptag/0x00710102"
    
    Private oRDOSess As Redemption.RDOSession
    Private WithEvents Items As Outlook.Items
    
    Public Sub ClearSelectedConversationIds()
        Dim Message As Object
        For Each Message In Application.ActiveExplorer.Selection
            ClearConversationId Message
            DoEvents
            DoEvents
        Next Message
        Debug.Print "Finished Processing All Selected Messages"
    End Sub
    
    Private Sub Application_Startup()
        Dim olNS As Outlook.NameSpace
        Dim Inbox  As Outlook.MAPIFolder
    
        Set olNS = Application.GetNamespace("MAPI")
        Set Inbox = olNS.GetDefaultFolder(olFolderInbox)
        Set Items = Inbox.Items
    End Sub
    
    Private Sub Items_ItemAdd(ByVal Item As Object)
        If TypeOf Item Is Outlook.MailItem Then
            ClearConversationId Item
        End If
    End Sub
    

    Main Sub:

    Public Sub ClearConversationId(ByVal Item As Object)
        On Error GoTo Reset
    
        ' Initialize the Redemption instance if doesn't already exist
        If oRDOSess Is Nothing Then
            Debug.Print "Creating Redemption Object ..."
            Set oRDOSess = New Redemption.RDOSession
            With Outlook.GetNamespace("MAPI")
                 .Logon
                oRDOSess.MAPIOBJECT = .MAPIOBJECT
            End With
        End If
    
        Dim oRDOItem As Object
        Set oRDOItem = oRDOSess.GetMessageFromID(Item.EntryID, Item.Parent.StoreID)
    
        If oRDOItem.ConversationTopic <> Item.Subject Or Not IsEmpty(oRDOItem.Fields(ConversationIndexField)) Then
            Debug.Print "Fixing " & Item.Subject
            oRDOItem.ConversationTopic = Item.Subject
            oRDOItem.Fields(ConversationIndexField) = Null
            oRDOItem.Save
        End If
        Exit Sub
    Reset:
        Debug.Print "Error: " + Err.Description
        Set oRDOSess = Nothing
        End Sub
    

提交回复
热议问题