Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
696 views
in Technique[技术] by (71.8m points)

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

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 MailItem. I wrote the following method and created a rule so it would trigger on email subjects like "Order# 345 - Reply from vendor" and "Order # 345 - Reply from customer" and put them in the same thread. Unfortunately the conversationTopic is a read only property.

Does anyone know a way around this or perhaps a better way of accomplishing the same task? Thanks!

Sub ModifyConversationTopic(Item As Outlook.MailItem)
    Dim regex As RegExp
    Dim newMailItem As Outlook.MailItem
    newMailItem = Item.Copy
    Set regex = New RegExp
    regex.IgnoreCase = False
    regex.Global = True
    regex.Pattern = "(Order# [0-9]+) .*"
    If regex.Test(newMailItem.Subject) Then
        Dim matches As MatchCollection
        Set matches = regex.Execute(newMailItem.Subject)
        Set topic = matches.Item(0)
        MsgBox ("OH YEAH" + topic)
        newMailItem.ConversationTopic = topic
        newMailItem.Save
    End If
End Sub
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Was looking for pretty much the exact same thing, this doesn't seem to be possible with normally exposed objects as you point out, but VBA macro + Outlook Redemption allows conversation topic to be tweaked easily. Bonus, the original message subject is unchanged, but the messages still show in a nice neat conversation group.

Something like this, thrown into VBA Macro and then run this script as a Rule action when messages are received with whatever criteria you determine:

Sub MsgProcess(msg As MailItem)
    Dim oNS As Object
    Dim oRDOSess As Object
    Dim oRDOItem As Object
    Dim sEntryID As String
    Dim sStoreID As String

    Dim NewConversationTopic As String


    Set oRDOSess = CreateObject("Redemption.RDOSession")
    Set oNS = Nothing
    Set oNS = Outlook.GetNamespace("MAPI")
    oNS.Logon
    oRDOSess.MAPIOBJECT = oNS.MAPIOBJECT

    sEntryID = msg.EntryID
    sStoreID = msg.Parent.StoreID
    Set oRDOItem = oRDOSess.GetMessageFromID(sEntryID, sStoreID)

    'Apply what modifications to topic you want here - dumb example string manipulation shown
    NewConversationTopic = Replace(oRDOItem.ConversationTopic, "BLACK", "WHITE")

    oRDOItem.ConversationTopic = NewConversationTopic
    oRDOItem.Save
End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...