Reputation:
I found code here that almost does what I need.
I used the code to create a macro to add [SEND SECURE] to the variable objMsg
, which should be whatever is in the Subject Line.
Instead it erases text already in the Subject Line.
Sub InsertSubject()
Dim objMsg As Outlook.MailItem
'Get the currently open message'
Set objMsg = Outlook.Application.ActiveInspector.CurrentItem
objMsg.Subject = "[SEND SECURE] " & objMsg.Subject
'Destroy the object to avoid memory leaks'
objMsg.Send
Set objMsg = Nothing
End Sub
I figured out what is going wrong. I need to click out of the Subject line for it to capture. If you never click out of the Subject line before initiating the macro, it will not capture the Subject line.
Upvotes: 1
Views: 249
Reputation: 9209
Based on your comment about tabbing out of the Subject line, you can simply save the message.
Sub InsertSubject()
Dim objMsg As MailItem
'Get the currently open message'
Set objMsg = ActiveInspector.CurrentItem
objMsg.Save
objMsg.Subject = "[SEND SECURE] " & objMsg.Subject
objMsg.Send
'Destroy the object to avoid memory leaks'
Set objMsg = Nothing
End Sub
Upvotes: 1