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
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
Using Outlook Redemption, I was able to merge selected Mail Items into a single conversation with the following code. I modeled it off of @fredless's answer above for my needs.
Public Sub MergeConversations()
Dim NewConversationTopic As String
Dim msg As MailItem
Dim msgSel As Selection
Dim oRDOSess, oNS, objRDOitem As Object
Set msgSel = Nothing
Set msgSel = Application.ActiveExplorer.Selection
If msgSel.Count <= 1 Then
MsgBox ("Multiple Mail Items have not been selected!")
Set msgSel = Nothing
Exit Sub
End If
Set msg = msgSel.Item(1)
NewConversationTopic = msg.ConversationTopic
Set msg = Nothing
Set oRDOSess = CreateObject("Redemption.RDOSession")
Set oNS = Nothing
Set oNS = Outlook.GetNamespace("MAPI")
oNS.Logon
oRDOSess.MAPIOBJECT = oNS.MAPIOBJECT
For Each msg In msgSel
Set objRDOitem = oRDOSess.GetMessageFromID(msg.EntryID, msg.Parent.StoreID)
objRDOitem.ConversationTopic = NewConversationTopic
'the following line is from this answer
objRDOitem.Fields("http://schemas.microsoft.com/mapi/proptag/0x00710102") = Null
objRDOitem.Save
Set objRDOitem = Nothing
Next msg
Set msgSel = Nothing
Set msg = Nothing
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With