Several users asked me how to add secure to the message subject before sending the message.
I need a way to change the subject of an email after I hit send. Specific example: If I have a subject that says "meeting", after I hit send I would like the subject to be automatically changed to "meeting {Secure Message}"
You can either use an ItemSend macro to add Secure automatically, or use macro to selectively add Secure to the message.
ItemSend
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim strSecure As String strSecure = "Secure " & Item.Subject Item.Subject = strSecure End Sub
To use ItemSend and add Secure to the subject of some, but not all, messages, you need to use an If statement. If the message meets the condition, Secure is added to the subject.
In this example, we're testing for domains in the address. If a match is found, the subject is edited and sent. To send to all EXCEPT some domains, use
If InStr(LCase(strRecip), arrDomain(n)) = 0 Then.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim Recipients As Outlook.Recipients Dim recip, strRecip As String Dim i, n Dim arrDomain As Variant Dim strSecure As String Set Recipients = Item.Recipients For i = Recipients.Count To 1 Step -1 Set recip = Recipients.Item(i) strRecip = recip.Address & " " & strRecip Next i ' Set up the array arrDomain = Array("domain1.com", "domain2.com") ' Go through the array and look for a match, then do something For n = LBound(arrDomain) To UBound(arrDomain) If InStr(LCase(strRecip), arrDomain(n)) > 0 Then strSecure = "Secure " & Item.Subject Item.Subject = strSecure Exit Sub End If Next n End Sub
Macro Button on Ribbon
To use this macro, customize the message ribbon by adding a new button near the existing Send button.
Sub AddSecure() Dim Item As MailItem Set Item = Application.ActiveInspector.CurrentItem() Dim strSecure As String strSecure = "Secure " & Item.Subject Item.Subject = strSecure Item.Send End Sub
Add Secure to Reply
Like the previous macro, you'll create a button on the ribbon for this macro. Click the button instead of Reply.
Public Sub SecureReply() Dim objApp As Outlook.Application Dim objItem As MailItem Dim strSecure As String Set objApp = Application Set objItem = objApp.ActiveExplorer.Selection.Item(1) Set Item = objItem.Reply strSecure = "Secure " & Item.Subject Item.Subject = strSecure Item.Display End Sub
How to use Macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, itâs at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To use the macro code in ThisOutlookSession:
- Expand Project1 and double click on ThisOutlookSession.
- Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)
More information as well as screenshots are at How to use the VBA Editor
More Information
Message Security and Classification Tools
Secure E-mail Services
Hello Diane,
I have tested the above macro. I would like to confirm if its possible to prefix the subject line with the word "Secure"? Instead of changing the complete subject line?
Because when i compose a new message in outlook 2013 and enter my own subject then after i click on the ribbon i created for secure message, its removes the existing subject line and overwrite with the word secure.
Kindly assist.
Thanks
Krish
Is there a way to do this but in the body of the email? So instead of adding 'passphrase' to the subject line when I click the button, I'd like to add it to the body of the email (ideally in white) and then immediately send the message. This is my current code:
`Sub AddSecure()
Dim Item As MailItem
Set Item = Application.ActiveInspector.CurrentItem()
Dim strSecure As String
strSecure = Item.Subject & " [Passphrase]"
Item.Subject = strSecure
Item.Send
ObjMail.Send
End Sub'
Hi Diane,
I tried your code above however when doing the send using the code above always put secure in the subject line. How do I get it to only show the secure when sending to anyone else other than the domain I enter into the arrDomain?
To add it to all EXCEPT the domains listed in the array, use
If InStr(LCase(strRecip), arrDomain(n)) = 0 Then
Thank you. It works great!!
That would be wonderful. Thank you, Diane.
It's the last macro on the page now.
Hi Diane,
I came across this article and found it rather interesting and applicable to my situation. For me, the idea of having a button that added Secure to a subject line is perfect. I've created a quick step to create a message with Secure in the subject line but that doesn't work with replies. I like the Macro referenced above except for the fact that it immediately sends the email. It seems that it could be a good fit with a little tweaking. Basically, I'd like it to act like the Reply button. So, highlight the message, click the macro button. It adds Secure to the subject line and opens the message like Reply does. I suppose the ultimate solution would be something that would either create a New message with Secure in the subject or Reply to a message and add Secure to the subject line.
Thanks,
Dave
That won't be hard to do. I'm on a tablet tonight but will try to update the page with a new version tomorrow.