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

Posted on 2006-05-25
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
    LVL 76

    Expert Comment

    by:David Lee
    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.

    LVL 3

    Author Comment

    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


    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
    LVL 3

    Author Comment

    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
    No problem.  Contact me if you run into any problems when you do get around to using it.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    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 …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now