Outlook 2007 Beta Documentation - Blocked Attachments

[This is now documented here: https://msdn.microsoft.com/en-us/library/bb820936.aspx]

This is preliminary documentation for Outlook 2007 Beta 2. It does not apply to earlier versions of Outlook.

Blocked Attachments
Microsoft Outlook includes a feature that blocks attachments that are considered unsafe. The attachments which are blocked can vary from client to client depending on how Outlook is configured and on policies the administrator may have applied. See https://support.microsoft.com/kb/829982 for more information on how this is configured.

Custom code can query to see if a particular attachment is considered blocked by Outlook using the IAttachmentSecurity interface. This interface exposes a function, IsAttachmentBlocked, which will analyze a file name and report if this attachment is considered blocked by Outlook and won’t be shown in the UI or indexed.

Definition

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

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

Usage

This interface can be obtained by calling QueryInterface on the MAPI session object, requesting IID_IAttachmentSecurity. IsAttachmentBlocked will return true in pfBlocked if the attachment is considered blocked by Outlook and won’t be shown in the UI or indexed

 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