2017-01-02 2 views
0

내 작업은 주어진 날짜 사이의 모든 메일을 검색하는 매우 간단합니다.MAPI API를 사용하여 특정 날짜 사이에 특정 메일 검색

나는 IMAPITable::Restrict 전화를 사용하거나 직접 pHrQueryAllRows으로 지정해야한다는 것을 알고 있지만 Microsoft에서 제공 한 API를 고려할 때 너무 복잡해 보입니다. 내가 날짜 x와 y 사이의 메일을 검색하기 위해 다음과 같은 구조체를 사용하려면 어떻게해야

typedef struct _SRestriction 
{ 
    ULONG rt;   /* Restriction type */ 
    union 
    { 
     SComparePropsRestriction resCompareProps; /* first */ 
     SAndRestriction    resAnd; 
     SOrRestriction    resOr; 
     SNotRestriction    resNot; 
     SContentRestriction   resContent; 
     SPropertyRestriction  resProperty; 
     SBitMaskRestriction   resBitMask; 
     SSizeRestriction   resSize; 
     SExistRestriction   resExist; 
     SSubRestriction    resSub; 
     SCommentRestriction   resComment; 
     SAnnotationRestriction  resAnnotation; // OFFICEDEV: not backwards compatible with Office 11 and older 
     SCountRestriction   resCount;  // OFFICEDEV: not backwards compatible with Office 11 and older 
    } res; 
} SRestriction; 

:

는 SRestriction 구조체 (Mapidefs.h로)을 감안할 때?

편집 :

SPropValue* pStartTime = nullptr; 
pfnMAPIAllocateBuffer_(sizeof(SPropValue), 
    reinterpret_cast<LPVOID*>(&pStartTime)); 

ZeroMemory(pStartTime, sizeof(SPropValue)); 

SPropValue* pStopTime = nullptr; 
pfnMAPIAllocateBuffer_(sizeof(SPropValue), 
    reinterpret_cast<LPVOID*>(&pStopTime)); 

ZeroMemory(pStopTime, sizeof(SPropValue)); 

SRestriction* pConditions = nullptr; 
pfnMAPIAllocateBuffer_(sizeof(SRestriction) * 2, 
    reinterpret_cast<LPVOID*>(&pConditions)); 

pConditions[0].rt = RES_PROPERTY; 
pConditions[0].res.resProperty.relop = RELOP_GT; 
pStartTime->ulPropTag = 
    pConditions[0].res.resProperty.ulPropTag = 
    PR_MESSAGE_DELIVERY_TIME; 

////////////// 
SYSTEMTIME stStart = { 0 }; 
stStart.wSecond=0; 
stStart.wMinute=0; 
stStart.wHour=9; 
stStart.wDay=1; 
stStart.wMonth=1; 
stStart.wYear=2017; 
FILETIME ftStart; 
SystemTimeToFileTime(&stStart, &ftStart); 
pStartTime->Value.ft = ftStart; 
/////////////// 

pConditions[0].res.resProperty.lpProp = pStartTime; 

pConditions[1].rt = RES_PROPERTY; 
pConditions[1].res.resProperty.relop = RELOP_LE; 
pStopTime->ulPropTag = 
    pConditions[1].res.resProperty.ulPropTag = 
    PR_MESSAGE_DELIVERY_TIME; 

////////////// 
SYSTEMTIME stStop = { 0 }; 
stStop.wSecond = 0; 
stStop.wMinute=12; 
stStop.wHour=14; 
stStop.wDay=18; 
stStop.wMonth=1; 
stStop.wYear=2017; 
FILETIME ftStop; 
SystemTimeToFileTime(&stStop, &ftStop); 
pStartTime->Value.ft = ftStop; 
/////////////// 

pConditions[1].res.resProperty.lpProp = pStopTime; 

spSRestriction_.reset(new SRestriction); //#igal add deallocation 
spSRestriction_->rt = RES_AND; 
spSRestriction_->res.resAnd.cRes = 2; 
spSRestriction_->res.resAnd.lpRes = pConditions; 
+1

이것은 하나의 필드이므로 한 번에 하나씩 필드를 채울 필요가 없습니다. 나는 당신이 필요하다고 생각한다. 그리고 두 가지 소품 제한 (시작일보다 좋고 종료일보다 큼)이 포함 된 제한 –

답변

0

RES_AND (2, (RES_PROPERTY, RELOP_GT) (RES_PROPERTY, RELOP_LE)). 값은 각 RES_PROPERTY SRestriction에 대해 SRestriction.lpProp.Value.ft에 저장됩니다.

당신은 OutlookSpy에서 Outlook 또는 사용자가 만든 다양한 SRestriction 조건을 볼 수 있습니다 - Outlook에서 폴더 트리보기에서 "검색 폴더"노드 아래 Outlook에서 볼 검색 폴더 중 하나를 선택하고에 IMAPIFolder 버튼을 클릭 할 수 있습니다 OutlookSpy 리본을 클릭하고 GetSearchCriteria 탭으로 이동하십시오 (탭은 검색 폴더에만 표시됨).

+0

그리고 실제 날짜는 어디에서 채울 수 있습니까? 그리고 어떤 형식으로? –

+0

위의 업데이트 된 답변보기 –

+0

OutLookSpy에서 해당 옵션을 찾을 수 없으며 SRestriction 옵션도 특정 폴더의 메일이나 모든 메일에 적용됩니까? –

관련 문제