In this edition of How to Make Outlook More Like GMail, I address the problem of replying to a message that you have sent. Inexplicably, Outlook creates a message addressed to you. That make sense from the standpoint that a reply to should be addressed to the sender. But then there’s the whole common sense thing. You know that thing where you wouldn’t send an email to yourself.
I’m a chronic reply-er to my own sent messages. I send a message to someone that omits some key information like, oh I don’t know, the attachment, and need to send a quick follow up.
In general, I need to monitor newly created email messages, see if they’re addressed to me, and then figure out to whom they should be addressed. That starts with creating an Inspectors variable declared WithEvents. The WithEvents keyword exposes the events of the object declared. In the ThisOutlookSession module:
Private WithEvents olInsp As Inspectors
Private Sub Application_Startup()
Set olInsp = Application.Inspectors
Now by using the dropdown boxes at the top of the code module, I can select olInsp from the left and NewInspector (the only event for this type of object) from the right. I cobbled this next bit of code from various places, so not only will I not be giving proper attribution, but I don’t know what it all means either.
Private Sub olInsp_NewInspector(ByVal Inspector As Inspector)
Dim olMi As MailItem
Dim olParent As MailItem
Dim olRecip As Recipient
If Inspector.currentItem.Size = 0 And Inspector.currentItem.Class = olMail Then
Set olMi = Inspector.currentItem
If olMi.Recipients.Count = 1 Then
If olMi.Recipients.Item(1).Name = "Dick Kusleika" Then
Set olParent = FindParentMessage(olMi)
If Not olParent Is Nothing Then
For Each olRecip In olParent.Recipients
I’m not sure why (or if) I need to check that the size of the item is zero, but there it is. The second part of the If statement makes sure it’s email because an Inspector can hold any type of item. Next I check that there is only one Recipient and that it’s me. The FindParentMessage sub is shown below and it finds the message I’m replying to.
As long as everything works up to this point, I’m removed as the only Recipient and every recipient from the parent message is added. To find the parent message, I use the following code, which I borrowed from Sue Mosher. Sue says
The key to finding the parent message for a reply or forward is knowing that all messages in a conversation have the same ConversationTopic value, while the ConversationIndex is increased by 5 bytes with each exchange.
Function FindParentMessage(msg As Outlook.MailItem) As Outlook.MailItem
Dim sFind As String
Dim sIndex As String
Dim olFldr As Outlook.MAPIFolder
Dim olItems As Outlook.Items
Dim olMi As Object
sIndex = Left$(msg.ConversationIndex, Len(msg.ConversationIndex) - 10)
If Application.ActiveInspector Is Nothing Then
Set olFldr = Application.ActiveExplorer.Selection.Item(1).Parent
Set olFldr = Application.ActiveInspector.currentItem.Parent
sFind = "[ConversationTopic] = " & Chr$(34) & msg.ConversationTopic & Chr$(34)
Set olItems = olFldr.Items.Restrict(sFind)
For Each olMi In olItems
If olMi.Class = olMail Then
If olMi.ConversationIndex = sIndex Then
Set FindParentMessage = olMi
I could reply from an open message (ActiveInspector) or from a list of messages (ActiveExplorer) and I get the folder depending on which it was. I find all of the messages in that folder with the same ConversationTopic, then loop through them to determine which has the correct ConversationIndex.
And that’s it. Now when I reply to a message I’ve sent, it’s addressed properly.