Partager via


How to: Determine if Outlook Downloaded Only the Header of a Message

How to: Determine if Outlook Downloaded Only the Header of a Message

This topic shows a code sample in Visual C++ that uses the named property dispidHeaderItem to determine whether Outlook has downloaded only the header of a message or the header and the body of a message.

  BOOL bIsHeader(LPMESSAGE lpMessage)
{
    HRESULT         hRes = S_OK;
    BOOL            bRet = false;
    ULONG	    ulVal = 0;
    LPSPropValue    lpPropVal = NULL;
    LPSPropTagArray lpNamedPropTag = NULL;
    MAPINAMEID      NamedID = {0};
    LPMAPINAMEID    lpNamedID = NULL;
NamedID.lpguid = (LPGUID) &PSETID_Common;
NamedID.ulKind = MNID_ID;
NamedID.Kind.lID = dispidHeaderItem;
lpNamedID = &NamedID;
hRes = lpMessage->GetIDsFromNames(1, &lpNamedID, NULL, &lpNamedPropTag);

if (lpNamedPropTag && 1 == lpNamedPropTag->cValues)
{
lpNamedPropTag->aulPropTag[0] = CHANGE_PROP_TYPE(lpNamedPropTag->aulPropTag[0], PT_LONG);

//Get the value of the property.
hRes = lpMessage->GetProps(lpNamedPropTag, 0, &ulVal, &lpPropVal);
if (lpPropVal && 1 == ulVal && PT_LONG == PROP_TYPE(lpPropVal->ulPropTag) && lpPropVal->Value.ul)
{
    bRet = true;
}
}

MAPIFreeBuffer(lpPropVal);
MAPIFreeBuffer(lpNamedPropTag);
return bRet;

}