Home > Microsoft Exchange Tips > Outlook and Outlook Web Access Tips > Microsoft Outlook script: Banish blank email subject lines
Exchange Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

OUTLOOK AND OUTLOOK WEB ACCESS TIPS

Microsoft Outlook script: Banish blank email subject lines


Serdar Yegulalp
08.08.2006
Rating: -5.00- (out of 5)


Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


If you're constantly forgetting to fill in the subject field of your Microsoft Outlook emails, or you want to create a client-side provision that forces users to provide a subject lines for all company email messages, this tip offers a macro that solves that dilemma.

Courtesy of Outlook MVP Sue Mosher, the code snippet below intercepts any outgoing Microsoft Outlook email that does not have the Subject field filled in.

VIEW MEMBER FEEDACK TO THIS MICROSOFT OUTLOOK TIP
To create the macro in Outlook 2003, go to Tools -> Macro -> Visual Basic Editor (this feature has to be installed). In Microsoft Office Outlook Objects -> ThisOutlookSession, paste the following code:

 
Private Sub Application_ItemSend _
  (ByVal Item As Object, Cancel As Boolean)
    Dim strMessage As String
    Dim lngRes As Long
    If Item.Subject = "" Then
        Cancel = True
        strMessage = "Please fill in the subject before sending."
        MsgBox strMessage, _
               vbExclamation + vbSystemModal, "Missing Subject"
        Item.Display
    End If
End Sub

If you already have code in the Application_Itemsend section, you can include this before or after it (probably afterward); just make sure there are no duplicate variable declarations or anything else that might interfere with it running.

About the author: Serdar Yegulalp is editor of the Windows Power Users Newsletter.

More on Microsoft Outlook, scripts and programming:
Quick VBA script -- Attachment reminder for Outlook

Manage attachments with Outlook Attachment Sniffer

The Microsoft Outlook Toolbox

Exchange Server scripts and programming tips

Microsoft Outlook tips and resources
MEMBER FEEDBACK TO THIS TIP

Is there a code to automatically delete blank senders (i.e., blank From fields) in emails?
—Neil P.

******************************************

According to Sue Mosher, the MVP from whom I derived the script, this is actually not possible unless you are in an Exchange environment and you create the email message in code by using an Outlook.MailItem object. In theory you can set the SendOnBehalfOfName property, but again, that only really works in Exchange environments.

I found a blog post that discusses this issue in some detail: Redemption still needed with Outlook VSTO 2005. I believe the Redemption toolkit for Outlook allows things like this to be done.
—Serdar Yegulalp, tip author

******************************************

Thank you very much for this useful tip. I have a question: Does this macro function in Microsoft Outlook XP?

I use Microsoft Outlook XP SP 3. I followed the instructions but, unfortunately, the macro ran only the first time. When I closed the application and ran it again, the macro did not function.
—Filip J.

******************************************

Unfortunately, I haven't tested the script in Microsoft Outlook XP. I would check to make sure you don't have macros persistently disabled in Outlook.
—Serdar Yegulalp, tip author

******************************************

I'm using Microsoft Outlook 2003. This script worked the first time I tried it. But when I closed Microsoft Outlook and reopened it, the script did not work. Any ideas?"
—Nikhil G.

******************************************

It sounds like you have scripting disabled by default whenever Microsoft Outlook is opened. You need to allow scripts to run in Microsoft Outlook to make this work consistently.

To enable scripting in Microsoft Outlook, go to the program's menu:
Tools -> Macro -> Macro Security. This will let you set the level of security for Microsoft Outlook macros, which are typically locked down pretty heavily by default.
—Serdar Yegulalp, tip author

******************************************

I wanted to know how to install Visual Basic Editor for creating macros. I am presently using Microsoft Outlook 2007. Also, would this script run successfully on Microsoft Outlook 2007?
—Arjun K.

******************************************

In Microsoft Outlook 2007, if you want to enable the Developer tab (which includes the Visual Basic macro editor), click on the Microsoft Office logo button when a message is open and select "Editor Options" at the bottom right corner. Under "Popular," select "Show the Developer tab in the ribbon." This enables access to the Office Visual Basic Editor.
—Serdar Yegulalp, tip author

******************************************

How do we set permission for the scripts to execute in Microsoft Outlook 2007? This is similar to member Nikhil G.'s issue above. Thanks.
—Edward A.

******************************************

Go to Tools -> Trust Center -> Macro Security and select "No security check for macros." Note that this assumes you have good control over what kinds of macros might be executed.
—Serdar Yegulalp, tip author

******************************************

I used Sue Mosher's script to banish blank subject lines along with a related script that would check for attachments in the message body (and send a warning if no attachment is present). I put the attachment script first, and then the blank subject script follows. The first works, but the second does not. Any idea why this isn't working? These are, as you know, VB scripts in Microsoft Outlook.

(Click link to view the two subroutines that banish blank email subject lines and check for attachments.)

—Steve R.

******************************************

I believe the second Sub should also be ItemSend (not Sending), so the two can actually be consolidated into a single subroutine.
—Serdar Yegulalp, tip author

Do you have comments on this tip? Let us know.

Please let others know how useful this tip was via the rating scale below. Do you know a helpful Exchange Server, Microsoft Outlook or SharePoint tip, timesaver or workaround? Email the editors to talk about writing for SearchExchange.com.

Rate this Tip
To rate tips, you must be a member of SearchExchange.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Outlook and Outlook Web Access Tips
How to access SharePoint sites through Microsoft Outlook
What makes Microsoft Outlook 2007's Search feature special?
OWA won't load after applying Exchange 2007 SP1 security patch
Minimize remote and mobile Outlook Web Access (OWA) security risks
Uncovering Microsoft Outlook 2007's hidden diagnostic tools
How Microsoft Office Communicator enhances Outlook 2007 functionality
How to improve Outlook Web Access (OWA) security
Alleviate Outlook Web Access (OWA) email attachment security issues
Tool exports messages from Microsoft Outlook to Unix .EML file format
DetachPipe: Outlook add-in tool saves and restores email attachments

Microsoft Outlook
Does Exchange cached mode work with all versions of Microsoft Outlook?
How to access SharePoint sites through Microsoft Outlook
What makes Microsoft Outlook 2007's Search feature special?
Uncovering Microsoft Outlook 2007's hidden diagnostic tools
How Microsoft Office Communicator enhances Outlook 2007 functionality
Microsoft Outlook .PST file FAQs
Tool exports messages from Microsoft Outlook to Unix .EML file format
DetachPipe: Outlook add-in tool saves and restores email attachments
Install the Outlook Connector to use Hotmail in Microsoft Outlook
A few favorite Microsoft Exchange Server blogs
Microsoft Outlook Research

Microsoft Exchange Server Scripts and Programming
How to generate HTML reports with the Exchange Management Shell (EMS)
Use the Exchange Management Shell Set command to block senders
How to test Exchange Management Shell commands
Grant or deny permissions to access a user's Exchange 2007 mailbox
Control query results with Exchange Management Shell's Format command
How to use Exchange Management Shell's Filter command
How to use the Exchange Management Shell command syntax
Fix OWA message size limit issue after Exchange 2007 SP1 upgrade
Automatically save Microsoft Outlook email attachments to disk
Can an admin create out-of-office messages from ESM or AD?

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
bacn  (SearchExchange.com)
email bankruptcy  (SearchExchange.com)
offline folder file  (SearchExchange.com)
OST file  (SearchExchange.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsWebcastsWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2004 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts