I have used the following code in Outlook 2010 successfully:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim myItem As MailItem
Set myItem = Application.ActiveInspector.CurrentItem
If InStr(1, myItem.Subject, "@gtd") > 0 Then
Dim objMe As Recipient
Set objMe = Item.Recipients.Add("[email protected]")
' for testing only -- Set objMe = Item.Recipients.Add("[email protected]")
objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing
End If
Set myItem = Nothing
End Sub
Sub GTDTracking()
Dim initialSubj As String
Dim finalSubj As String
Dim myItem As MailItem
Set myItem = Application.ActiveInspector.CurrentItem
initialSubj = myItem.Subject
finalSubj = initialSubj & " (@gtd)"
myItem.Subject = finalSubj
End Sub
I have recently switched to Outlook 2013. It offers the option to hit reply and have the new reply window be docked right in the message list. However, if I reply that way my code fails at this line:
Set myItem = Application.ActiveInspector.CurrentItem
If I open up the message by double-clicking so it is not docked to the message list, the code runs just fine.