Click here to Skip to main content
12,892,796 members (60,493 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 9 Apr 2008

Outlook add-in to unlock blocked attachments in .NET

, 9 Apr 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
An Outlook add-in written in .NET which allows blocked file attachments to be unlocked.


By default, Microsoft Outlook is configured to block specific file attachments based on file extensions. This is useful in most scenarios to prevent the spread of email viruses and to keep your PC secure. However, sometimes you may want to override this behaviour in order to open attachments from known sources which are otherwise inaccessible. For a list of blocked file extensions, see here.

For some reason, the standard edition of Microsoft Outlook does not allow users to configure or disable these security settings, though it is possible to control behaviour by tweaking the registry.

The .NET Forms application included in this article is an example built on the Automation and Extensibility framework, which allows the registry settings to be controlled via an Outlook add-in. This adds an additional tab to the Options menu of Outlook, and allows security settings to be adjusted for custom behaviour.


The attachment security features within Microsoft Outlook are controlled via two string registry keys, Level1Add and Level1Remove. These keys can be added at the following location, and allow the default behaviour for blocking attachments to be overridden:

Note: 10.0 will vary depending on the version installed

When added, each key represents a list of semi-colon separated file extensions to either block (Level1Add) or unblock (Level1Remove). Security can be further customised with more keys for level2 security settings; however, this is beyond the scope of this article.

Outlook Unlocker

The OutlookUnlocker add-in is installed by running the Setup.exe. This adds an Attachment Unlocker tab to the Options menu within Outlook, which can be accessed via the Tools menu. Enter the extensions to be blocked or unblocked into the blocked/unblocked lists accordingly. Do this by typing text into the relevant input box and pressing Enter.

Once the extension is added, it can be moved to the blocked or unblocked lists by highlighting the item and using the < and > arrows. Items can be removed from the blocked and unblocked lists by highlighting an item and using the X button. Extensions not listed revert to the default Outlook behaviour for those extension types. You will need to restart Outlook for changes to take effect.

How it works

The solution was built on top of the Automation and Extensibility framework using the Visual Studio Shared Add-in project template for .NET. This creates an add-in template project, as well as an installation project for installing the add-in.

In brief, the extensibility framework allows managed .NET assemblies to communicate with unmanaged COM code via proxy (shim) objects. This allows IDEs such as Outlook to raise events which the add-ins can respond to in order to integrate with the application; such as when they are loaded or unloaded. The interface IDTExtensibility2 is commonly used for this purpose to hook into the application events.

The Outlook Unlocker solution consists of a class named Connect. This is the implementation of the IDTExtensibility2 interface created by the project template. In order to hook an additional tab to the Options menu, we must register for the OptionsPagesAdd event as follows during the OnConnection event:

// On connection register for the OptionsPagesAdd event
public void OnConnection(object application, Extensibility.ext_ConnectMode 
            connectMode, object addInInst, ref System.Array custom)
    Microsoft.Office.Interop.Outlook.Application applicationObject = 
    applicationObject.OptionsPagesAdd += new 
// When the OptionsPagesAdd is fired, add the custom property page 
private void applicationObject_OptionsPagesAdd(PropertyPages Pages)
    Pages.Add(new Unlocker(), "Attachment Unlocker");

When the OptionsPagesAdd event is fired, the custom usercontrol named Unlocker is added to the Pages collection. The control implements an interface derived from a reference to the Microsoft.Office.Interop.Outlook assembly, which allows the control to act as a tab within the Options menu of Outlook.

With the custom control added, the implementation of the Unlocker usercontrol uses standard .NET behaviour to interact with the user and perform read/write functionality on the registry; thus controlling the security behaviour.


  • Initial release, April 2008

Further reading


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United Kingdom United Kingdom
Mike Carlisle - Technical Architect with over 20 years experience in a wide range of technologies.


You may also be interested in...

Comments and Discussions

GeneralRuntime error loading Com Add-Ins Pin
sppradip10-Aug-10 19:27
membersppradip10-Aug-10 19:27 
GeneralRe: Runtime error loading Com Add-Ins Pin
TheCodeKing11-Aug-10 9:03
memberTheCodeKing11-Aug-10 9:03 
GeneralRe: Runtime error loading Com Add-Ins Pin
sppradip11-Aug-10 17:36
membersppradip11-Aug-10 17:36 
GeneralInstallation [modified] Pin
RVW22-Apr-08 2:59
memberRVW22-Apr-08 2:59 
GeneralRe: Installation Pin
TheCodeKing23-Apr-08 8:54
memberTheCodeKing23-Apr-08 8:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 9 Apr 2008
Article Copyright 2008 by TheCodeKing
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid