Microsoft KB Archive/919199

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

Article ID: 919199

Article Last Modified on 4/25/2007

-

APPLIES TO


 * Microsoft Office Outlook 2007

-





INTRODUCTION
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
DEFINE_GUID(IID_IAttachmentSecurity,           0xB2533636,            0xC3F3, 0x416f, 0xBF, 0x04, 0xAE, 0xFE, 0x41, 0xAB, 0xAA, 0xE2); MAPIMETHOD(IsAttachmentBlocked) \ (LPCWSTR pwszFileName, BOOL *pfBlocked) IPURE;
 * 1) define MAPI_IATTACHMENTSECURITY_METHODS(IPURE) \

DECLARE_MAPI_INTERFACE_(IAttachmentSecurity, IUnknown) {   BEGIN_INTERFACE MAPI_IUNKNOWN_METHODS(PURE) MAPI_IATTACHMENTSECURITY_METHODS(PURE) };

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 &quot;true&quot; in &quot;pfBlocked&quot; 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;

HRESULT hRes = S_OK; 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

Additional query words: OL2007 Outlook2007

Keywords: kbexpertiseinter kbinfo KB919199

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.