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

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.
LVL 3
xy8088Asked:
Who is Participating?
 
David LeeCommented:
xy8088,

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
                .Send
            End With
            Item.Delete
        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
0
 
David LeeCommented:
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.

Cheers!
0
 
xy8088Author Commented:
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.
0
 
xy8088Author Commented:
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.
0
 
David LeeCommented:
No problem.  Contact me if you run into any problems when you do get around to using it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.