VBOffice

Merge Email Conversations

This sample shows how to merge any emails to the same conversation.

Last modified: 2016/10/27 | Accessed: 30.112  | #107
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

If you group the folder view by conversation, you'd ideally see all emails of the same conversation grouped together, and the reply to a previous emails will be indented. Outlook doesn't use the Subject field for the sorting, but the ConversationIndex. That's why it doesn't work to simply change the subject, the message would still be shown in a different conversation.

Outlook, or Exchange, respectively, aren't very good in setting the correct index so that the indentation often doesn't work. And if a sender doesn't reply on your message but creates a new one instead, then the grouping of actually together belonging messages is totally messed.

This script shows how to correct a grouping. Copy the code to the module ThisOutlookSession in the VBA editor. Also, you need to install the Redemption. The developer version is free for the private use.

When changing the conversation the message automatically gets the same subject, too. The variable KeepOriginalSubject=True controls that the message keeps its original subject instead. If you don't want that, set the value of the variable to False.

How to use it: Open an email, then select all the other emails in the folder that should belong to the same conversation as the opened email. Then start the script by pressing alt+f8. (I'd recommend you test it with a few test messages. Group the folder view by Conversation to see the result.)


tip  How to add macros to Outlook
Private m_Session As Object

Public Sub MergeConversation()
  Dim Sel As Outlook.Selection
  Dim obj As Object
  Dim Parent As Redemption.RDOMail
  Dim Mail As Redemption.RDOMail
  Dim i As Long
  Dim KeepOriginalSubject As Boolean
  Dim Subject As String
  
  KeepOriginalSubject = True

  Set m_Session = CreateObject("redemption.rdosession")
  m_Session.MAPIOBJECT = Application.Session.MAPIOBJECT

  Set obj = Application.ActiveInspector.CurrentItem
  Set Parent = GetRdoMessage(obj)

  Set Sel = Application.ActiveExplorer.Selection
  For i = 1 To Sel.Count
    Set obj = Sel(i)
    Set Mail = GetRdoMessage(obj)
    Subject = Mail.Subject
    Mail.CreateConversationIndex Parent
    If KeepOriginalSubject Then
      Mail.Subject = Subject
    End If
    Mail.Save
  Next
End Sub

Private Function GetRdoMessage(Item As Object) As Redemption.RDOMail
  Dim e$, s$

  If Not Item Is Nothing Then
    e = Item.EntryID
    If Not Item.Parent Is Nothing Then
      s = Item.Parent.StoreID
    End If
    If Len(e) Then
      If Len(s) Then
        Set GetRdoMessage = m_Session.GetMessageFromID(e, s)
      Else
        Set GetRdoMessage = m_Session.GetMessageFromID(e)
      End If
    End If
  End If
End Function
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.
email  Send a message