Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Autofill Subject Line? 1

Status
Not open for further replies.

Hakala

Technical User
Apr 26, 2006
144
US
Hi, Tek-tippers!

We now have to use secure email in our office and our customer service department would like their Outlook (MS Outlook 2002) to automatically put the secure email tag in every email.

So when they create an email, the subject line would already say
SECURED:
in the subject line.

Anybody know if there's a way to do this? Thanks!


Michelle Hakala
 
I can think of two ways to accomplish what you're asking, but both requires the use of macros.

Method 1:

In Outlook, press ALT-F11, paste the following code and save.
Code:
Sub New_Secured_Email()
   Dim ol_app As Outlook.Application
   Dim mail_item As Outlook.MailItem
   
   Set ol_app = New Outlook.Application
   Set mail_item = ol_app.CreateItem(olMailItem)

   mail_item.Subject = "SECURED:  "
   mail_item.Display
End Sub

Go to and read "Creating the Button" section.

Method 2:

In Outlook, press ALT-F11, paste the following code and save. Send yourself two test emails, one with "SECURE:" in the subject line and one email without.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
   Dim subject_line As String
   
   subject_line = Trim(Item.Subject)
   
   If InStr(1, UCase(subject_line), "SECURED:") <> 1 Then
      Item.Subject = "SECURED:  " & subject_line
   Else
      Item.Subject = subject_line
   End If
End Sub
 
Thanks, WinblowsME!

I tried Method 1 and when I click my new toolbar button, nothing seems to happen. I tried putting a setpoint in the code so I could watch it run, but I never get to the setpoint (I work in Access quite a bit and this always works there).

So I tried Method 2, but the test emails went through just like they did before, and since I had to type the subject line tag of SECURED: there really isn't any benefit.

I must be doing something wrong?


Michelle Hakala
 
The problem with this method is that if a user is replying to a message or if a user is forwarding a message, "SECURE:" will not be added to the beginning of the subject line.
Code:
Scratch what I wrote.  Create a new email message with "SECURED:" in the subject line and pick File -> SaveAs -> Save As Type -> Outlook Template (*.oft) and rename the template.

At the following link, start reading at the section "Creating the buttons."

[URL unfurl="true"]http://articles.techrepublic.com.com/5100-6346_11-5178650.html[/URL]

The following code would take care of the new/reply/forward emails if you can get the code to work. Try using the below code and send a test email to yourself WITHOUT "SECURE:" in the subject line and check your sent items folder.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
   Dim subject_line As String
   
   subject_line = Trim(Item.Subject)
   
   If InStr(1, UCase(subject_line), "SECURED:") <> 1 Then
      Item.Subject = "SECURED:  " & subject_line
   Else
      Item.Subject = subject_line
   End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top