确定 Outlook 是否仅下载邮件头
适用于:Outlook 2013 | Outlook 2016
本主题演示 Visual C++ 中的一个代码示例,该示例使用名为 PidLidHeaderItem 规范属性来确定Microsoft Outlook 2013是否只下载了消息的标头或消息的标头和正文。
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;
}