Learn how to a build a cloud-first strategyRegister Now


Need a rule for Outlook. Bonce back messages that have no subject line.

Posted on 2006-05-25
Medium Priority
Last Modified: 2010-04-08
There is an employee here who refuses to put a subject line in her emails. She just leaves the subject line blank. That is very annoying. I need a rule or a macro or something that will take any email that I recieve that has a blank subject line and will delete the email and send back a message to the sender explaining why it was deleted. That way if she wants to email me she will be forced to put something in the subject line.

Or something similar to that.
Question by:xy8088
  • 3
  • 2
LVL 76

Expert Comment

by:David Lee
ID: 16765636
Hi xy8088,

Via a macro I can trap a blank subject line and delete the message.  Sending a response is a problem though.  Outlook's security model won't allow code to send a message without manual intervention.  Any attempt to send from code triggers a security dialog-box warning that a program is trying to send on your behalf and asking if you want to allow it to continue.  An alternative would be to build the response message, display it on screen, and allow you to click the Send button.


Author Comment

ID: 16817523
I really don't need this anymore, but for future reference I'dd be interested in seeing how the macro would work, just to increase my own knowledge and skills in that area. So if you can create it and post it you'll get the points. I'd rather have the dialog box pop up that you described in the first part of your post. Thanks.
LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 16820813

Here's the code for doing this.  Follow these instructions to use it.  The code below will send a message back to the sender of any message arriving with a blank subject line.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Outlook Objects in the Project pane, then click on ThisOutlookSession
4.  Copy the script below
5.  Paste the script into the right-hand pane of the VB Editor
6.  Edit the code as desired
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools->Macro->Security
10.  Set Security Level to Medium
11.  Close Outlook
12.  Start Outlook
13.  A dialog-box will appear telling you the ThisOutlookSession contains macros and asking if you want to enable them.  Say yes.
14.  Test the macro by sending yourself a message with a blank subject line.

Private Sub olkInboxItems_ItemAdd(ByVal Item As Object)
    Dim olkResponse As Outlook.MailItem
    If Item.Class = olMail Then
        If Item.Subject = "" Then
            Set olkResponse = Application.CreateItem(olMailItem)
            With olkResponse
                'Edit the subject as desired
                .Subject = "Message With Blank Subject"
                'Edit the message as desired
                .HTMLBody = "Your message with a blank subject line has been deleted without having been read.  " _
                    & "If you want me to read your messages, then please include a subject."
                .Recipients.Add Item.SenderEmailAddress
            End With
        End If
    End If
End Sub

Private Sub Application_Quit()
    Set olkInboxItems = Nothing
End Sub

Private Sub Application_Startup()
    Set olkInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Author Comment

ID: 16848635
Cool thanks! Probably won't get a chance to try it for a couple weeks though as we are in the middle of a big changeover/migration type thing.
LVL 76

Expert Comment

by:David Lee
ID: 16850542
No problem.  Contact me if you run into any problems when you do get around to using it.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question