How to use the IAttachmentSecurity API to verify whether an attachment is considered to be blocked in Outlook

Article translations Article translations
Article ID: 919199 - View products that this article applies to.
Expand all | Collapse all

On This Page


Microsoft Office Outlook 2007 includes a feature that blocks attachments that are considered unsafe. Custom code can query to verify whether Outlook considers a particular attachment to be blocked. The code does this by using the IAttachmentSecurity API.


Blocked attachments

The attachments that are blocked by Outlook 2007 can vary from client to client. Which attachments are blocked depends on how Outlook 2007 is configured and on policies that the administrator has applied.

For more information about how Outlook blocks attachments, click the following article number to view the article in the Microsoft Knowledge Base:
829982 Cannot open attachments in Microsoft Outlook

The IAttachmentSecurity API exposes the IsAttachmentBlocked function. This function analyzes a file name. Then, the IsAttachmentBlocked function reports whether the file is considered to be blocked by Outlook. If the file is blocked, it is not shown in or indexed in Outlook 2007.

Definition of the IAttachmentSecurity API

			0xC3F3, 0x416f, 0xBF, 0x04, 0xAE, 0xFE, 0x41, 0xAB, 0xAA, 0xE2);
MAPIMETHOD(IsAttachmentBlocked) \
		(LPCWSTR pwszFileName, BOOL *pfBlocked) IPURE; 

DECLARE_MAPI_INTERFACE_(IAttachmentSecurity, IUnknown)

Usage of the IAttachmentSecurity API

This interface can be obtained by calling the QueryInterface function on the MAPI session object, requesting IID_IAttachmentSecurity. IsAttachmentBlocked will return "true" in "pfBlocked" if the attachment is considered blocked by Outlook, and therefore is not shown in or indexed in Outlook 2007.
HRESULT IsAttachmentBlocked(LPMAPISESSION lpMAPISession, LPCWSTR pwszFileName, BOOL* pfBlocked)
	if (!lpMAPISession || !pwszFileName || !pfBlocked) return MAPI_E_INVALID_PARAMETER;

	IAttachmentSecurity* lpAttachSec = NULL;
	BOOL bBlocked = false;

	hRes = lpMAPISession->QueryInterface(IID_IAttachmentSecurity,(void**)&lpAttachSec);
	if (SUCCEEDED(hRes) && lpAttachSec)
		hRes = lpAttachSec->IsAttachmentBlocked(pwszFileName,&bBlocked);
	if (lpAttachSec) lpAttachSec->Release();

	*pfBlocked = bBlocked;
	return hRes;
}// IsAttachmentBlocked


Article ID: 919199 - Last Review: April 25, 2007 - Revision: 1.2
  • Microsoft Office Outlook 2007
kbexpertiseinter kbinfo KB919199

Give Feedback


Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from