Can I modify Conversation ID in Outlook by VBA to group independent Emails?

前端 未结 2 822
南方客
南方客 2021-02-20 08:56

I do receive a lot of mails sent by various robots. I can identify Emails easily by subject (for example: \"Response to ticket 123\"). Unfortunately each email is generated aut

2条回答
  •  广开言路
    2021-02-20 09:11

    I was able to solve this myself by using Redemption to get write-access to the MAPI properties of ConversationTopic and ConversationIndex.

    While apparently ConversationTopic is used at first for grouping messages, also ConversationIndex plays a role in grouping: It does not only carry the sorting time stamp, but the first bytes are a conversation code that must match across all emails of a conversation. Otherwise they are still not grouped, even with same topic. See here for details: https://msdn.microsoft.com/en-us/library/ms528174(v=exchg.10).aspx

    Luckily, setting the Index to Null apparently makes Outlook pay attention only to the topic, so we don't need to re-calculate a new index.

    My working code:

    Dim oNS As Object
    Dim oRDOSess As Object
    Dim oRDOItem As Object
    
    Debug.Print "Creating Redemption Object ..."
    ' This requires: http://www.dimastr.com/redemption/download.htm
    Set oRDOSess = CreateObject("Redemption.RDOSession")
    Set oNS = Nothing
    Set oNS = Outlook.GetNamespace("MAPI")
    oNS.Logon
    oRDOSess.MAPIOBJECT = oNS.MAPIOBJECT
    
    Set oRDOItem = oRDOSess.GetMessageFromID(incomingMail.EntryID, incomingMail.Parent.StoreID)
    
    Debug.Print "Trying to change conversation topic ..."
    oRDOItem.ConversationTopic = incomingMail.Subject
    
    Debug.Print "Trying to change conversation index ..."
    oRDOItem.Fields("http://schemas.microsoft.com/mapi/proptag/0x00710102") = Null
    
    Debug.Print "Saving modified mail item ..."
    oRDOItem.Save
    

提交回复
热议问题