Hi all:
My organization has started prepending "[EXTERNAL EMAIL]" to subject lines. Some of the people I correspond with are frustrated by this, especially when replies end up with multiple copies of that string. My goal is to remove that text (at least for certain people).
Using (very helpful) Slipstick resources, (e.g., VBA for incoming emails, removing text from subject lines), I got my VBA working to remove the text in question from the subject. Hooray!
However, I quickly learned that the subject is not the same as conversationTopic, which is what I and others see displayed in the "Subject" column of my outlook folders. Thus, the problem of losing precious space in the subject field was not quite solved. Using more Slipstick and Stackexchange resources (subject + conversation topic, modify conversation topic), I got into Redemption. I don't fully understand Redemption, but I got some code working - mostly (the code, which resides in ThisOutlookSession, follows). And, thus, to my question:
In essence, when I watch emails come in, what I see is the following:
Thanks *very* much in advance,
Andrew
System info: Office 365, Version 1901; Windows 10
Screen capture showing a opened email overlaid on the inbox, with different subject vs. conversationTopic, and the notification that I made a copy:
Code:
My organization has started prepending "[EXTERNAL EMAIL]" to subject lines. Some of the people I correspond with are frustrated by this, especially when replies end up with multiple copies of that string. My goal is to remove that text (at least for certain people).
Using (very helpful) Slipstick resources, (e.g., VBA for incoming emails, removing text from subject lines), I got my VBA working to remove the text in question from the subject. Hooray!
However, I quickly learned that the subject is not the same as conversationTopic, which is what I and others see displayed in the "Subject" column of my outlook folders. Thus, the problem of losing precious space in the subject field was not quite solved. Using more Slipstick and Stackexchange resources (subject + conversation topic, modify conversation topic), I got into Redemption. I don't fully understand Redemption, but I got some code working - mostly (the code, which resides in ThisOutlookSession, follows). And, thus, to my question:
In essence, when I watch emails come in, what I see is the following:
- the subject is successfully changed (i.e., when I double click on an email, the subject is simply "Some text"
- the conversationTopic is changed (i.e., the subject I see in the folder view changes from "[EXTERNAL EMAIL] Some text" to "Some text")
- the conversationTopic reverts to its original value after a second or two (i.e., the subject I see in the folder view goes back to "[EXTERNAL EMAIL] Some text")
Thanks *very* much in advance,
Andrew
System info: Office 365, Version 1901; Windows 10
Screen capture showing a opened email overlaid on the inbox, with different subject vs. conversationTopic, and the notification that I made a copy:
Code:
Code:
Option Explicit
Private objNS As Outlook.NameSpace
Private WithEvents objNewMailItems As Outlook.items
Private Sub Application_Startup()
Dim objMyInbox As Outlook.MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set objMyInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objNewMailItems = objMyInbox.items
Set objMyInbox = Nothing
End Sub
Private Sub objNewMailItems_ItemAdd(ByVal Item As Object)
' for testing (this MsgBox does indeed pop up)
MsgBox "Message subject: " & Item.Subject & vbCrLf & "Message sender: " & Item.SenderName & " (" & Item.SenderEmailAddress & ")"
Debug.Print "conv topic = " & Item.ConversationTopic & ", subject = " & Item.Subject
' get a new string for the subject - and hopefully the conversationTopic
Dim arrStrings As Variant, i As Long
Dim strNewConversationTopic As String
arrStrings = Array("[EXTERNAL EMAIL] ", "RE:", "Re:", "Fw:", "FW:", "etc.")
For i = 0 To UBound(arrStrings)
Item.Subject = Trim(Replace(Item.Subject, arr(i), "", , , vbTextCompare))
Next
strNewConversationTopic = Item.Subject
'changing the subject does not change the conversationTopic
Debug.Print "NEW target conversation topic = " & strNewConversationTopic
'prepare for Redemption
Dim oRDOSess, oNS, objRDOitem As Object
Set oRDOSess = CreateObject("Redemption.RDOSession")
Set oNS = Nothing
Set oNS = Outlook.GetNamespace("MAPI")
oNS.Logon
oRDOSess.MAPIOBJECT = oNS.MAPIOBJECT
'change conversation topic and save item
Set objRDOitem = oRDOSess.GetMessageFromID(Item.EntryID, Item.Parent.StoreID)
objRDOitem.ConversationTopic = strNewConversationTopic
objRDOitem.Fields("http://schemas.microsoft.com/mapi/proptag/0x00710102") = Null
objRDOitem.Save
Set objRDOitem = Nothing
Item.Save
Set Item = Nothing
End Sub
Last edited by a moderator: