We want to offer our users the ability to add “Confidential” to the beginning of the subject line of an Outlook mail message.
Sub InsertBeforeSubjectLine() Dim olkMsg As Outlook.mailItem Set olkMsg = Outlook.Application.ActiveInspector.CurrentItem ‘olkMsg.Save olkMsg.Subject = “CONFIDENTIAL ” & olkMsg.Subject End Sub
The above code functions well if the user has tabbed out of the Subjet field after typing their subject text. That action (tabbing out of the Subject field) gives the mail item a name, and VBA is able to read the current subject line. If the user hast NOT tabbed out of the Subject field, CONFIDENTIAL replaces the subject line text instead of being prefixed to it.
olkMsg.Save, which I’ve commented out above, resolves the issue, except for one thing: if the user Cancels the message (Sytem Control, “X” at upper right of window) the saved message remains in the Drafts folder. (Sending the message deletes the item from the Drafts folder.)
Is there a way to get the subject line without saving the message, and thus risking having the message remain in the Drafts folder for the user to deal with at a later time?
Thanks.