Export (0) Print
Expand All

How to: Verify an Attachment is Blocked

Last modified: June 25, 2012

Applies to: Outlook

This code sample in C++ shows how to use the IAttachmentSecurity : IUnknown interface to find out whether an attachment is blocked by Microsoft Outlook 2010 or Microsoft Outlook 2013 for viewing and indexing.

IAttachmentSecurity : IUnknown is derived from the IUnknown interface. You can obtain the IAttachmentSecurity : IUnknown interface by calling IUnknown::QueryInterface on the MAPI session object, requesting IID_IAttachmentSecurity. IAttachmentSecurity::IsAttachmentBlocked returns true in pfBlocked if the attachment is considered unsafe by Outlook 2010 or Outlook 2013 and is blocked for viewing and indexing in Outlook 2010 or Outlook 2013.

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; 

© 2014 Microsoft