9

When I receive Jira 4.2 notification emails in Outlook 2010, they do not get threaded. Of course by default Jira sends emails with the subjects like this: [JIRA] Created: (LTST-4) improve documentation, [JIRA] Assigned: (LTST-4) improve documentation. I read online that Outlook 2010 solely uses the Subject field to thread, so having the subjects as above will force those emails NOT to be threaded, which is indeed the case. Note that Gmail, for example, doesn't thread those same emails either (but Apple iPhone 4 mail app actually does!).

So I tweaked my Jira setup to remove the 'action performed' verb from the subject and now the email subjects all look like this: [JIRA] (LTST-4) improve documentation. And Gmail happily threads them. But Outlook 2010 still doesn't!

Is there anything I can do in terms of Jira configuration or Outlook configuration to force Outlook 2010 to thread Jira notification emails?

Thanks, Kirill

5

The following VBA macro leaves only 1 message per Jira issue in your Inbox. It also deletes messages about Resolved/Closed issues, since I don't need to look at these

' Tools>References: Microsoft VBScript Regular Expressions 5.5, Microsoft Scripting Runtime

Sub RemoveDuplicateJiraKeys()
    Dim i As Object
    Dim re As New RegExp
    Dim m As MatchCollection
    Dim d As New Dictionary
    Dim act As String ' Commented, Resolved, Updated...
    Dim key As String ' e.g. RS-123

    re.Pattern = "\[JIRA\] (.*?): \((.*?)\)"
    For Each i In Session.GetDefaultFolder(olFolderInbox).Items
      ' luckily the items come in chronological order
      Set m = re.Execute(i.Subject)
      If m.Count >= 1 Then
        act = m(0).SubMatches(0)
        key = m(0).SubMatches(1)
        If d.Exists(key) Then d(key).Delete: d.Remove (key) ' same Jira key but older
        If act = "Resolved" Or act = "Closed" Then i.Delete Else d.Add key, i
      End If
    Next i
End Sub
1

Outlook 2010 arranges conversations (threading) by subject only. Removing the 'action' from the email subject in JIRA should keep them together in your Outlook inbox. It sounds like you might need to check your Outlook settings. More info available here.

  • 1
    Yeah, that's what I thought. Doesn't happen, unfortunately. Messages with the same exact subject are NOT threaded together. I've also seen the link you mention, nothing relevant there. – kirillka May 17 '11 at 13:35
0

I used a combination of the other answer post, and this article to write my own macro that uses the Redemption library to merge the conversations.

This scans the current folder, picking out any jira emails, extracts the issue key from the subject. If it's not seen that key before, it saves the conversation index in a collection based on the issue key, and if it has seen it before, it updates the email with the saved conversation index.

Dim ConversationIndexes As New Collection

Sub GroupJira()
    Dim MapiNamespace As Object
    Dim RdoSession As Object

    Dim Item As Object
    Dim RdoItem As Object

    Dim ConversationKey As String
    Dim ConversationIndex As String

    ' Get all the required handles
    Set MapiNamespace = Outlook.GetNamespace("MAPI")
    MapiNamespace.Logon
    Set RdoSession = CreateObject("Redemption.RDOSession")
    RdoSession.MAPIOBJECT = MapiNamespace.MAPIOBJECT

    'Setup some subject patterns to extract the issue key
    Dim Matches As MatchCollection
    Dim UpdateSubjectPattern As New RegExp
    UpdateSubjectPattern.Pattern = "\[JIRA\] \(([A-Z]+-[0-9]+)\) .*"
    Dim MentionedSubjectPattern As New RegExp
    MentionedSubjectPattern.Pattern = "\[JIRA\] .* mentioned you on ([A-Z]+-[0-9]+) \(JIRA\)"

    For Each Item In Outlook.ActiveExplorer.CurrentFolder.Items
        If TypeOf Item Is MailItem Then
            If Left(Item.Subject, 7) = "[JIRA] " Then
                ' Get a key for this conversation, opic for now
                ConversationKey = Item.ConversationTopic
            Set Matches = UpdateSubjectPattern.Execute(Item.Subject)
            If Matches.Count >= 1 Then ConversationKey = Matches(0).SubMatches(0)
            Set Matches = MentionedSubjectPattern.Execute(Item.Subject)
            If Matches.Count >= 1 Then ConversationKey = Matches(0).SubMatches(0)

                ' Get any saved indexes
                ConversationIndex = ""
                On Error Resume Next
                ConversationIndex = ConversationIndexes.Item(ConversationKey)
                On Error GoTo 0

                If ConversationIndex = "" Then
                    ' Save this index if not seen yet
                    ConversationIndexes.Add Item.ConversationIndex, ConversationKey
                ElseIf Item.ConversationIndex <> ConversationIndex Then
                    ' Set the item's index if it has
                    Set RdoItem = RdoSession.GetMessageFromID(Item.EntryID, Item.Parent.StoreID)
                    RdoItem.ConversationIndex = ConversationIndex
                    RdoItem.Save
                End If
            End If
        End If
    Next Item
End Sub

This requires the following libraries:

  • Redemption library for full RDO access, required to set the conversation index (this does not require elevation to register it)
  • A reference to the Microsoft VBScript Regular Expressions 5.5 library to extract issue keys from the mail subjects.

Oh, and you also need to knobble your macro security settings to run it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.