本文整理汇总了C++中LPMAPITABLE类的典型用法代码示例。如果您正苦于以下问题:C++ LPMAPITABLE类的具体用法?C++ LPMAPITABLE怎么用?C++ LPMAPITABLE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPMAPITABLE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DebugPrintEx
// Clear the current list and get a new one with whatever code we've got in LoadMAPIPropList
void CRulesDlg::OnRefreshView()
{
HRESULT hRes = S_OK;
if (!m_lpExchTbl || !m_lpContentsTableListCtrl) return;
if (m_lpContentsTableListCtrl->IsLoading()) m_lpContentsTableListCtrl->OnCancelTableLoad();
DebugPrintEx(DBGGeneric,CLASS,_T("OnRefreshView"),_T("\n"));
if (m_lpExchTbl)
{
LPMAPITABLE lpMAPITable = NULL;
// Open a MAPI table on the Exchange table property. This table can be
// read to determine what the Exchange table looks like.
EC_MAPI(m_lpExchTbl->GetTable(0, &lpMAPITable));
if (lpMAPITable)
{
EC_H(m_lpContentsTableListCtrl->SetContentsTable(
lpMAPITable,
dfDeleted,
NULL));
lpMAPITable->Release();
}
}
} // CRulesDlg::OnRefreshView
示例2: GetCurrentProfileName
HRESULT GetCurrentProfileName(IN LPMAPISESSION& lpSession, OUT std::string* szProfileName)
{
if ( !szProfileName->empty() )
return S_OK;
HRESULT hr = GetCurrentMAPISession(lpSession);
if ( FAILED(hr) )
return hr;
LPMAPITABLE lpStatusTable = NULL;
SRestriction sres;
SPropValue spvResType;
LPSRowSet pRows = NULL;
LPTSTR lpszProfileName = NULL;
SizedSPropTagArray(2, Columns) =
{
2,
PR_DISPLAY_NAME,
PR_RESOURCE_TYPE
};
hr = lpSession->GetStatusTable(NULL, &lpStatusTable);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->SetColumns((LPSPropTagArray)&Columns, NULL);
if ( SUCCEEDED(hr) )
{
spvResType.ulPropTag = PR_RESOURCE_TYPE;
spvResType.Value.ul = MAPI_SUBSYSTEM;
sres.rt = RES_PROPERTY;
sres.res.resProperty.relop = RELOP_EQ;
sres.res.resProperty.ulPropTag = PR_RESOURCE_TYPE;
sres.res.resProperty.lpProp = &spvResType;
if ( SUCCEEDED(hr) )
hr = lpStatusTable->Restrict(&sres, TBL_ASYNC);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
if ( SUCCEEDED(hr) )
hr = lpStatusTable->QueryRows(1,0,&pRows);
if (SUCCEEDED(hr))
{
lpszProfileName = pRows->aRow[0].lpProps[0].Value.lpszA;
*szProfileName = lpszProfileName;
}
}
ULRELEASE(lpStatusTable);
FREEPROWS(pRows);
if ( FAILED(hr) )
PR_TRACE((0, prtIMPORTANT, "GetCurrentProfileName failed"));
return hr;
}
示例3: ComputeSingleFolderSize
ULONGLONG ComputeSingleFolderSize(
_In_ LPMAPIFOLDER lpFolder)
{
HRESULT hRes = S_OK;
LPMAPITABLE lpTable = NULL;
LPSRowSet lpsRowSet = NULL;
SizedSPropTagArray (1, sProps) = { 1, {PR_MESSAGE_SIZE} };
ULONGLONG ullThisFolderSize = 0;
// Look at each item in this folder
WC_MAPI(lpFolder->GetContentsTable(0, &lpTable));
if (lpTable)
{
WC_MAPI(HrQueryAllRows(lpTable, (LPSPropTagArray)&sProps, NULL, NULL, 0, &lpsRowSet));
if (lpsRowSet)
{
for(ULONG i = 0; i < lpsRowSet->cRows; i++)
{
if (PROP_TYPE(lpsRowSet->aRow[i].lpProps[0].ulPropTag) != PT_ERROR)
ullThisFolderSize += lpsRowSet->aRow[i].lpProps[0].Value.l;
}
MAPIFreeBuffer(lpsRowSet);
lpsRowSet = NULL;
}
lpTable->Release();
lpTable = NULL;
}
DebugPrint(DBGGeneric, "Content size = %I64u\n", ullThisFolderSize);
// printf("Content size = %I64d\n", ullThisFolderSize);
WC_MAPI(lpFolder->GetContentsTable(MAPI_ASSOCIATED, &lpTable));
if (lpTable)
{
WC_MAPI(HrQueryAllRows(lpTable, (LPSPropTagArray)&sProps, NULL, NULL, 0, &lpsRowSet));
if (lpsRowSet)
{
for(ULONG i = 0; i < lpsRowSet->cRows; i++)
{
if (PROP_TYPE(lpsRowSet->aRow[i].lpProps[0].ulPropTag) != PT_ERROR)
ullThisFolderSize += lpsRowSet->aRow[i].lpProps[0].Value.l;
}
MAPIFreeBuffer(lpsRowSet);
lpsRowSet = NULL;
}
lpTable->Release();
lpTable = NULL;
}
DebugPrint(DBGGeneric, "Total size = %I64u\n", ullThisFolderSize);
// printf("Total size = %I64d\n", ullThisFolderSize);
return ullThisFolderSize;
} // ComputeSingleFolderSize
示例4: ExtractContents
void COLAddrFolder::ExtractContents()
{
m_contents.clear();
if (!m_initRef->Inited())
return;
if (!m_pABCont)
return;
LPMAPITABLE pContentTable = NULL;
if (SUCCEEDED(m_pABCont->GetContentsTable(0, &pContentTable)))
{
SizedSPropTagArray ( 4, sptCols ) = {4, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_EMAIL_ADDRESS, PR_ADDRTYPE};
LPSRowSet pRowSet = NULL;
if (SUCCEEDED(g_pMAPIEDK->pHrQueryAllRows(pContentTable, reinterpret_cast<SPropTagArray*>(&sptCols), NULL, NULL, 0, &pRowSet)))
{
m_contents.reserve(pRowSet->cRows);
for (ULONG i = 0; i < pRowSet->cRows; ++i)
{
string addrType;
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_ADDRTYPE))
{
addrType = lpDN->Value.lpszA ? lpDN->Value.lpszA : "";
}
if (0 == addrType.compare("SMTP"))
{
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_EMAIL_ADDRESS))
{
if (lpDN->Value.lpszA)
m_contents.push_back(lpDN->Value.lpszA);
}
}
else
{
if (LPSPropValue lpDN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_SMTP_ADDRESS))
{
if (lpDN->Value.lpszA)
m_contents.push_back(lpDN->Value.lpszA);
}
}
}
g_pMAPIEDK->pFreeProws(pRowSet);
}
}
if (pContentTable)
pContentTable->Release();
}
示例5: PrintReceiveFolderTable
void PrintReceiveFolderTable(_In_ LPMDB lpMDB)
{
HRESULT hRes = S_OK;
LPMAPITABLE lpReceiveFolderTable = NULL;
WC_MAPI(lpMDB->GetReceiveFolderTable(0, &lpReceiveFolderTable));
if (FAILED(hRes))
{
printf(_T("<receivefoldertable error=0x%x />\n"), hRes);
return;
}
printf(_T("<receivefoldertable>\n"));
if (lpReceiveFolderTable)
{
LPSPropTagArray sTags = (LPSPropTagArray)&sptRECEIVECols;
WC_MAPI(lpReceiveFolderTable->SetColumns(sTags, TBL_ASYNC));
}
if (SUCCEEDED(hRes))
{
LPSRowSet lpRows = NULL;
ULONG iRow = 0;
for (;;)
{
hRes = S_OK;
if (lpRows) FreeProws(lpRows);
lpRows = NULL;
WC_MAPI(lpReceiveFolderTable->QueryRows(
10,
NULL,
&lpRows));
if (FAILED(hRes) || !lpRows || !lpRows->cRows) break;
ULONG i = 0;
for (i = 0; i < lpRows->cRows; i++)
{
printf(_T("<properties index=\"%u\">\n"), iRow);
_OutputProperties(DBGNoDebug, stdout, lpRows->aRow[i].cValues, lpRows->aRow[i].lpProps, NULL, false);
printf(_T("</properties>\n"));
iRow++;
}
}
if (lpRows) FreeProws(lpRows);
}
printf(_T("</receivefoldertable>\n"));
if (lpReceiveFolderTable) { lpReceiveFolderTable->Release(); }
} // PrintReceiveFolderTable
示例6: CollectData
HRESULT MailboxDataCollector::CollectData(LPMAPITABLE lpStoreTable)
{
HRESULT hr = hrSuccess;
SRowSetPtr ptrRows;
enum {IDX_ENTRYID, IDX_MAILBOX_OWNER_ENTRYID, IDX_STORE_ENTRYIDS, IDX_ITEM_ENTRYIDS, IDX_MAX};
while (true) {
hr = lpStoreTable->QueryRows(50, 0, &ptrRows);
if (hr != hrSuccess)
goto exit;
if (ptrRows.size() == 0)
break;
for (SRowSetPtr::size_type i = 0; i < ptrRows.size(); ++i) {
std::pair<ArchiveStateCollector::ArchiveInfoMap::iterator, bool> res;
bool bComplete = true;
abentryid_t userId;
for (unsigned j = 0; bComplete && j < IDX_MAX; ++j) {
if (PROP_TYPE(ptrRows[i].lpProps[j].ulPropTag) == PT_ERROR) {
m_lpLogger->Log(EC_LOGLEVEL_WARNING, "Got uncomplete row, row %u, column %u contains error 0x%08x", i, j, ptrRows[i].lpProps[j].Value.err);
bComplete = false;
}
}
if (!bComplete)
continue;
if (ptrRows[i].lpProps[IDX_STORE_ENTRYIDS].Value.MVbin.cValues != ptrRows[i].lpProps[IDX_ITEM_ENTRYIDS].Value.MVbin.cValues) {
m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Mismatch in archive prop count, %u vs. %u", ptrRows[i].lpProps[IDX_STORE_ENTRYIDS].Value.MVbin.cValues, ptrRows[i].lpProps[IDX_ITEM_ENTRYIDS].Value.MVbin.cValues);
continue;
}
userId.assign(ptrRows[i].lpProps[IDX_MAILBOX_OWNER_ENTRYID].Value.bin);
res = m_mapArchiveInfo.insert(std::make_pair(userId, ArchiveStateCollector::ArchiveInfo()));
if (res.second == true)
m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Inserting row for user id %s", userId.tostring().c_str());
else
m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Updating row for user '" TSTRING_PRINTF "'", res.first->second.userName.c_str());
// Assign entryid
res.first->second.storeId.assign(ptrRows[i].lpProps[IDX_ENTRYID].Value.bin);
// Assign archives
m_lpLogger->Log(EC_LOGLEVEL_DEBUG, "Adding %u archive(s)", ptrRows[i].lpProps[IDX_STORE_ENTRYIDS].Value.MVbin.cValues);
for (ULONG j = 0; j < ptrRows[i].lpProps[IDX_STORE_ENTRYIDS].Value.MVbin.cValues; ++j) {
SObjectEntry objEntry;
objEntry.sStoreEntryId.assign(entryid_t(ptrRows[i].lpProps[IDX_STORE_ENTRYIDS].Value.MVbin.lpbin[j]));
objEntry.sItemEntryId.assign(entryid_t(ptrRows[i].lpProps[IDX_ITEM_ENTRYIDS].Value.MVbin.lpbin[j]));
res.first->second.lstArchives.push_back(objEntry);
}
}
}
exit:
return hr;
}
示例7: GetProfiles
void COLAddrBook::GetProfiles(Profiles& profiles)
{
profiles.clear();
LPPROFADMIN pProfAdmin = NULL;
if (SUCCEEDED(g_pMAPIEDK->pMAPIAdminProfiles(0, &pProfAdmin)))
{
LPMAPITABLE pProfTable = NULL;
if (SUCCEEDED(pProfAdmin->GetProfileTable(0, &pProfTable)))
{
SizedSPropTagArray ( 2, sptCols ) = {2, PR_DISPLAY_NAME, PR_DEFAULT_PROFILE};
LPSRowSet pRowSet = NULL;
if (SUCCEEDED(g_pMAPIEDK->pHrQueryAllRows(pProfTable, reinterpret_cast<SPropTagArray*>(&sptCols), NULL, NULL, 0, &pRowSet)))
{
for (ULONG i = 0; i < pRowSet->cRows; ++i)
{
bool bDefaultProfile = false;
if (LPSPropValue pPVN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_DEFAULT_PROFILE))
{
bDefaultProfile = pPVN->Value.b != 0;
}
if (LPSPropValue pPVN = g_pMAPIEDK->pPpropFindProp(pRowSet->aRow[i].lpProps, pRowSet->aRow[i].cValues, PR_DISPLAY_NAME))
{
profiles.push_back(std::make_pair(pPVN->Value.lpszA ? pPVN->Value.lpszA : "", bDefaultProfile));
}
}
g_pMAPIEDK->pFreeProws(pRowSet);
}
}
if (pProfTable)
pProfTable->Release();
}
if (pProfAdmin)
pProfAdmin->Release();
}
示例8: ProcessAttachments
// This method must be called AFTER the retrieval of the body,
// since the decision if an attachment is embedded or not is made
// based on the body type and contents
void CMapiMessage::ProcessAttachments()
{
LPSPropValue pVal = CMapiApi::GetMapiProperty(m_lpMsg, PR_HASATTACH);
bool hasAttach = true;
if (pVal) {
if (PROP_TYPE(pVal->ulPropTag) == PT_BOOLEAN)
hasAttach = (pVal->Value.b != 0);
CMapiApi::MAPIFreeBuffer(pVal);
}
if (!hasAttach)
return;
// Get the attachment table?
LPMAPITABLE pTable = NULL;
HRESULT hr = m_lpMsg->GetAttachmentTable(0, &pTable);
if (FAILED(hr) || !pTable)
return;
IterateAttachTable(pTable);
pTable->Release();
}
示例9: RunStoreValidation
HRESULT RunStoreValidation(char* strHost, char* strUser, char* strPass, char *strAltUser, bool bPublic, CHECKMAP checkmap)
{
HRESULT hr = hrSuccess;
LPMAPISESSION lpSession = NULL;
LPMDB lpStore = NULL;
LPMDB lpAltStore = NULL;
LPMDB lpReadStore = NULL;
LPMAPIFOLDER lpRootFolder = NULL;
LPMAPITABLE lpHierarchyTable = NULL;
LPSRowSet lpRows = NULL;
ULONG ulObjectType;
ULONG ulCount;
LPEXCHANGEMANAGESTORE lpIEMS = NULL;
// user
ULONG cbUserStoreEntryID = 0;
LPENTRYID lpUserStoreEntryID = NULL;
wstring strwUsername;
wstring strwAltUsername;
wstring strwPassword;
std::set<std::string> setFolderIgnore;
LPSPropValue lpAddRenProp = NULL;
ULONG cbEntryIDSrc = 0;
LPENTRYID lpEntryIDSrc = NULL;
ECLogger *const lpLogger = new ECLogger_File(EC_LOGLEVEL_FATAL, 0, "-");
hr = MAPIInitialize(NULL);
if (hr != hrSuccess) {
cout << "Unable to initialize session" << endl;
goto exit;
}
// input from commandline is current locale
if (strUser)
strwUsername = convert_to<wstring>(strUser);
if (strPass)
strwPassword = convert_to<wstring>(strPass);
if (strAltUser)
strwAltUsername = convert_to<wstring>(strAltUser);
hr = HrOpenECSession(lpLogger, &lpSession, "zarafa-fsck", PROJECT_SVN_REV_STR, strwUsername.c_str(), strwPassword.c_str(), (const char *)strHost, 0, NULL, NULL);
lpLogger->Release();
if(hr != hrSuccess) {
cout << "Wrong username or password." << endl;
goto exit;
}
if (bPublic) {
hr = HrOpenECPublicStore(lpSession, &lpStore);
if (hr != hrSuccess) {
cout << "Failed to open public store." << endl;
goto exit;
}
} else {
hr = HrOpenDefaultStore(lpSession, &lpStore);
if (hr != hrSuccess) {
cout << "Failed to open default store." << endl;
goto exit;
}
}
if (!strwAltUsername.empty()) {
hr = lpStore->QueryInterface(IID_IExchangeManageStore, (void **)&lpIEMS);
if (hr != hrSuccess) {
cout << "Cannot open ExchangeManageStore object" << endl;
goto exit;
}
hr = lpIEMS->CreateStoreEntryID(L"", (LPTSTR)strwAltUsername.c_str(), MAPI_UNICODE | OPENSTORE_HOME_LOGON, &cbUserStoreEntryID, &lpUserStoreEntryID);
if (hr != hrSuccess) {
cout << "Cannot get user store id for user" << endl;
goto exit;
}
hr = lpSession->OpenMsgStore(0, cbUserStoreEntryID, lpUserStoreEntryID, NULL, MDB_WRITE | MDB_NO_DIALOG | MDB_NO_MAIL | MDB_TEMPORARY, &lpAltStore);
if (hr != hrSuccess) {
cout << "Cannot open user store of user" << endl;
goto exit;
}
lpReadStore = lpAltStore;
} else {
lpReadStore = lpStore;
}
hr = lpReadStore->OpenEntry(0, NULL, &IID_IMAPIFolder, 0, &ulObjectType, (IUnknown **)&lpRootFolder);
if(hr != hrSuccess) {
cout << "Failed to open root folder." << endl;
goto exit;
}
if (HrGetOneProp(lpRootFolder, PR_IPM_OL2007_ENTRYIDS /*PR_ADDITIONAL_REN_ENTRYIDS_EX*/, &lpAddRenProp) == hrSuccess &&
Util::ExtractSuggestedContactsEntryID(lpAddRenProp, &cbEntryIDSrc, &lpEntryIDSrc) == hrSuccess) {
setFolderIgnore.insert(string((const char*)lpEntryIDSrc, cbEntryIDSrc));
}
hr = lpRootFolder->GetHierarchyTable(CONVENIENT_DEPTH, &lpHierarchyTable);
if (hr != hrSuccess) {
cout << "Failed to open hierarchy." << endl;
goto exit;
}
//.........这里部分代码省略.........
示例10: EncryptSignMessage
int CExtImpl::EncryptSignMessage(HWND hwnd,
IMessage *pmsg,
RECIPIENTDIALOGSTRUCT *prds,
PGPOptionListRef *pSignOptions)
{
IStream *pstrmBody = 0;
STATSTG StreamStats;
DWORD dwInSize;
UINT nOutSize;
BOOL bExchangeUser = FALSE;
char *pInput;
char *pOutput = NULL;
LPMAPITABLE ptableAttach = 0;
SizedSPropTagArray(1, tagaTable) = {
1, {PR_ATTACH_NUM}};
SRowSet *prAttach = 0;
PGPError nError = kPGPError_NoErr;
HRESULT hr;
char szName[256];
char szFile[256];
UIGetString(szName, sizeof(szName), IDS_LOGNAME);
UIGetString(szFile, sizeof(szFile), IDS_DLL);
pmsg->GetAttachmentTable(0, &ptableAttach);
HrQueryAllRows(ptableAttach, (SPropTagArray *)&tagaTable,
NULL, NULL, 0, &prAttach);
hr = pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READ,
0, (IUnknown**)&pstrmBody);
if (FAILED(hr))
{
UIDisplayStringID(hwnd, IDS_E_NOBODY);
ptableAttach->Release();
return kPGPError_ItemNotFound;
}
pstrmBody->Stat(&StreamStats, STATFLAG_NONAME);
dwInSize = StreamStats.cbSize.LowPart;
pInput = (char *) calloc(dwInSize+1, sizeof(char));
if (!pInput)
{
UIDisplayStringID(hwnd, IDS_E_NOMEMORY);
pstrmBody->Release();
ptableAttach->Release();
return kPGPError_OutOfMemory;
}
pstrmBody->Read(pInput, dwInSize, &dwInSize);
pstrmBody->Release();
pInput[dwInSize] = 0;
nError = EncryptSignBuffer(UIGetInstance(), hwnd, _pgpContext,
_tlsContext, szName, szFile, pInput,
dwInSize, prds, NULL, pSignOptions, (VOID ** )&pOutput,
&nOutSize, _bEncrypt, _bSign, FALSE);
if ((dwInSize > 0) && IsntPGPError(nError))
{
LARGE_INTEGER li = {0,0};
ULARGE_INTEGER uli = {1,0};
BOOL fPartied;
pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
pstrmBody->Seek(li, STREAM_SEEK_SET, NULL);
pstrmBody->Write("\0", 1, NULL);
pstrmBody->SetSize(uli);
pstrmBody->Commit(STGC_DEFAULT);
pstrmBody->Release();
RTFSync(pmsg, RTF_SYNC_BODY_CHANGED, &fPartied);
pmsg->OpenProperty(PR_BODY, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
}
if (IsntPGPError(nError))
{
LARGE_INTEGER li = {0,0};
ULARGE_INTEGER uli = {nOutSize + prAttach->cRows, 0};
BOOL fPartied;
pstrmBody->Seek(li, STREAM_SEEK_SET, NULL);
pstrmBody->Write(pOutput, nOutSize, NULL);
pstrmBody->SetSize(uli);
pstrmBody->Commit(STGC_DEFAULT);
pstrmBody->Release();
RTFSync(pmsg, RTF_SYNC_BODY_CHANGED, &fPartied);
PGPFreeData(pOutput);
}
free(pInput);
if (IsntPGPError(nError))
{
hr = pmsg->OpenProperty(PR_BODY_HTML, &IID_IStream, STGM_READWRITE,
MAPI_MODIFY, (IUnknown**)&pstrmBody);
//.........这里部分代码省略.........
示例11: ComputeFolderSize
ULONGLONG ComputeFolderSize(
_In_z_ LPWSTR lpszProfile,
_In_ LPMAPIFOLDER lpFolder,
_In_ ULONG ulFolder,
_In_z_ LPWSTR lpszFolder)
{
DebugPrint(DBGGeneric,"ComputeFolderSize: Calculating size (including subfolders) for folder %u / %ws from profile %ws \n", ulFolder, lpszFolder?lpszFolder:L"", lpszProfile);
// printf("ComputeFolderSize: Calculating size (including subfolders) for folder %i / %ws from profile %ws \n", ulFolder, lpszFolder?lpszFolder:L"", lpszProfile);
HRESULT hRes = S_OK;
if (lpFolder)
{
LPMAPITABLE lpTable = NULL;
LPSRowSet lpRow = NULL;
ULONG i = 0;
ULONGLONG ullSize = 0;
enum
{
ePR_DISPLAY_NAME_W,
ePR_ENTRYID,
ePR_FOLDER_TYPE,
NUM_COLS
};
static const SizedSPropTagArray(NUM_COLS, rgColProps) =
{
NUM_COLS,
PR_DISPLAY_NAME_W,
PR_ENTRYID,
PR_FOLDER_TYPE,
};
// Size of this folder
ullSize += ComputeSingleFolderSize(lpFolder);
// Size of children
WC_MAPI(lpFolder->GetHierarchyTable(MAPI_DEFERRED_ERRORS, &lpTable));
if (SUCCEEDED(hRes) && lpTable)
{
WC_MAPI(lpTable->SetColumns((LPSPropTagArray)&rgColProps, TBL_ASYNC));
if (!FAILED(hRes)) for (;;)
{
hRes = S_OK;
if (lpRow) FreeProws(lpRow);
lpRow = NULL;
WC_MAPI(lpTable->QueryRows(
50,
NULL,
&lpRow));
if (FAILED(hRes) || !lpRow || !lpRow->cRows) break;
for (i = 0; i < lpRow->cRows; i++)
{
hRes = S_OK;
// Don't look at search folders
if (PR_FOLDER_TYPE == lpRow->aRow[i].lpProps[ePR_FOLDER_TYPE].ulPropTag && FOLDER_SEARCH == lpRow->aRow[i].lpProps[ePR_FOLDER_TYPE].Value.ul)
{
continue;
}
if (PR_ENTRYID == lpRow->aRow[i].lpProps[ePR_ENTRYID].ulPropTag)
{
ULONG ulObjType = NULL;
LPMAPIFOLDER lpSubfolder = NULL;
WC_MAPI(lpFolder->OpenEntry(lpRow->aRow[i].lpProps[ePR_ENTRYID].Value.bin.cb,
(LPENTRYID)lpRow->aRow[i].lpProps[ePR_ENTRYID].Value.bin.lpb,
NULL,
MAPI_BEST_ACCESS,
&ulObjType,
(LPUNKNOWN *) &lpSubfolder));
if (SUCCEEDED(hRes) && lpSubfolder)
{
LPWSTR szDisplayName = L"";
if (PR_DISPLAY_NAME_W == lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].ulPropTag)
{
szDisplayName = lpRow->aRow[i].lpProps[ePR_DISPLAY_NAME_W].Value.lpszW;
}
ullSize += ComputeFolderSize(lpszProfile, lpSubfolder, 0, szDisplayName);
}
if (lpSubfolder) lpSubfolder->Release();
}
}
}
if (lpRow) FreeProws(lpRow);
}
if (lpTable) lpTable->Release();
return ullSize;
}
return 0;
} // ComputeFolderSize
示例12: return
HRESULT CWAB::IterateWABContents(CWabIterator *pIter, int *pDone)
{
if (!m_bInitialized || !m_lpAdrBook)
return( E_FAIL);
ULONG ulObjType = 0;
LPMAPITABLE lpAB = NULL;
ULONG cRows = 0;
LPSRowSet lpRowAB = NULL;
LPABCONT lpContainer = NULL;
int cNumRows = 0;
nsresult keepGoing;
HRESULT hr = E_FAIL;
ULONG lpcbEID = 0;
LPENTRYID lpEID = NULL;
ULONG rowCount = 0;
ULONG curCount = 0;
nsString uniStr;
// Get the entryid of the root PAB container
//
hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID);
if (HR_FAILED( hr))
goto exit;
ulObjType = 0;
// Open the root PAB container
// This is where all the WAB contents reside
//
hr = m_lpAdrBook->OpenEntry(lpcbEID,
(LPENTRYID)lpEID,
NULL,
0,
&ulObjType,
(LPUNKNOWN *)&lpContainer);
m_lpWABObject->FreeBuffer(lpEID);
lpEID = NULL;
if(HR_FAILED(hr))
goto exit;
// Get a contents table of all the contents in the
// WABs root container
//
hr = lpContainer->GetContentsTable( 0,
&lpAB);
if(HR_FAILED(hr))
goto exit;
hr = lpAB->GetRowCount( 0, &rowCount);
if (HR_FAILED(hr))
rowCount = 100;
if (rowCount == 0)
rowCount = 1;
// Order the columns in the ContentsTable to conform to the
// ones we want - which are mainly DisplayName, EntryID and
// ObjectType
// The table is gauranteed to set the columns in the order
// requested
//
hr =lpAB->SetColumns( (LPSPropTagArray)&ptaEid, 0 );
if(HR_FAILED(hr))
goto exit;
// Reset to the beginning of the table
//
hr = lpAB->SeekRow( BOOKMARK_BEGINNING, 0, NULL );
if(HR_FAILED(hr))
goto exit;
// Read all the rows of the table one by one
//
do {
hr = lpAB->QueryRows(1, 0, &lpRowAB);
if(HR_FAILED(hr))
break;
if(lpRowAB)
{
cNumRows = lpRowAB->cRows;
if (cNumRows)
{
LPTSTR lpsz = lpRowAB->aRow[0].lpProps[ieidPR_DISPLAY_NAME].Value.lpszA;
LPENTRYID lpEID = (LPENTRYID) lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
//.........这里部分代码省略.........
示例13: GetMapiProperty
void CMapiApi::GetStoreInfo( CMapiFolder *pFolder, long *pSzContents)
{
HRESULT hr;
LPMDB lpMdb;
if (pSzContents)
*pSzContents = 0;
if (!OpenStore( pFolder->GetCBEntryID(), pFolder->GetEntryID(), &lpMdb))
return;
LPSPropValue pVal;
/*
pVal = GetMapiProperty( lpMdb, PR_DISPLAY_NAME);
ReportStringProp( " Message store name:", pVal);
pVal = GetMapiProperty( lpMdb, PR_MDB_PROVIDER);
ReportUIDProp( " Message store provider:", pVal);
pVal = GetMapiProperty( lpMdb, PR_COMMENT);
ReportStringProp( " Message comment:", pVal);
pVal = GetMapiProperty( lpMdb, PR_ACCESS_LEVEL);
ReportLongProp( " Message store Access Level:", pVal);
pVal = GetMapiProperty( lpMdb, PR_STORE_SUPPORT_MASK);
ReportLongProp( " Message store support mask:", pVal);
pVal = GetMapiProperty( lpMdb, PR_STORE_STATE);
ReportLongProp( " Message store state:", pVal);
pVal = GetMapiProperty( lpMdb, PR_OBJECT_TYPE);
ReportLongProp( " Message store object type:", pVal);
pVal = GetMapiProperty( lpMdb, PR_VALID_FOLDER_MASK);
ReportLongProp( " Message store valid folder mask:", pVal);
pVal = GetMapiProperty( lpMdb, 0x8001001e);
ReportStringProp( " Message prop 0x8001001e:", pVal);
// This key appears to be the OMI Account Manager account that corresponds
// to this message store. This is important for IMAP accounts
// since we may not want to import messages from an IMAP store!
// Seems silly if you ask me!
// In order to test this, we'll need the registry key to look under to determine
// if it contains the "IMAP Server" value, if it does then we are an
// IMAP store, if not, then we are a non-IMAP store - which may always mean
// a regular store that should be imported.
pVal = GetMapiProperty( lpMdb, 0x80000003);
ReportLongProp( " Message prop 0x80000003:", pVal);
// ListProperties( lpMdb);
*/
pVal = GetMapiProperty( lpMdb, PR_IPM_SUBTREE_ENTRYID);
if (pVal) {
ULONG cbEntry;
LPENTRYID pEntry;
LPMAPIFOLDER lpSubTree = NULL;
if (GetEntryIdFromProp( pVal, cbEntry, pEntry)) {
// Open up the folder!
ULONG ulObjType;
hr = lpMdb->OpenEntry( cbEntry, pEntry, NULL, 0, &ulObjType, (LPUNKNOWN *) &lpSubTree);
MAPIFreeBuffer( pEntry);
if (SUCCEEDED( hr) && lpSubTree) {
// Find out if there are any contents in the
// tree.
LPMAPITABLE lpTable;
hr = lpSubTree->GetHierarchyTable( 0, &lpTable);
if (HR_FAILED(hr)) {
MAPI_TRACE2( "GetStoreInfo: GetHierarchyTable failed: 0x%lx, %d\n", (long)hr, (int)hr);
}
else {
ULONG rowCount;
hr = lpTable->GetRowCount( 0, &rowCount);
lpTable->Release();
if (SUCCEEDED( hr) && pSzContents)
*pSzContents = (long) rowCount;
}
lpSubTree->Release();
}
}
}
}
示例14: ulFlags
/// <summary>
/// <para name='Name'>OpenDefaultMessageStore</para>
/// <para name='Purpose'>Find and open the default message store</para>
/// </summary>
/// <param name='lppDefaultMDB'>[out] Pointer to the opened default message store</param>
/// <returns>HRESULT</returns>
/// <remarks>
/// <para name='Notes'>Adapted from MFCMapi's MAPIStoreFunctions.cpp\OpenDefaultMessageStore()</para>
/// <para name='Author'></para>
/// <para name='LastModified'>29Jan2016</para>
/// </remarks>
STDMETHODIMP ZybraxiSoft::CMailbox::OpenDefaultMessageStore(LPMDB * lppDefaultMDB)
{
HRESULT hr = S_OK;
LPMAPITABLE pStoresTable = NULL;
SPropValue sPropVal;
static SRestriction sRes;
LPSRowSet pSRowSet = NULL;
// Set up an enum to mask the numbers into pretty text
enum
{
EID,
NUM_COLS
};
// Set up a constant SPropTagArray
/*static const SizedSPropTagArray(NUM_COLS, sptEIDCol) =
{
NUM_COLS,
PR_ENTRYID,
};*/
static const struct _SPropTagArray_sptEIDCol
{
ULONG NUM_COLS;
ULONG aulPropTag[1];
} sptEIDCol =
{
NUM_COLS,
PR_ENTRYID
};
// Get our message stores table
// See https://msdn.microsoft.com/en-us/library/cc839751(v=office.15).aspx
if (FAILED(hr = m_lpSession->GetMsgStoresTable(
0, // ulFlags (not sure why we don't use MAPI_UNICODE)
&pStoresTable))) // [out] lppTable
{
ERROR_MSG_W_HR("Unable to get message stores table", hr);
goto CLEANUP;
}
// Set up our property value to restrict against
sPropVal.ulPropTag = PR_DEFAULT_STORE; // The proptag to check
sPropVal.Value.b = true; // what to check against
// Set up to restrict so QueryRows gets only the default store
sRes.rt = RES_PROPERTY; // Compare if property
sRes.res.resProperty.ulPropTag = PR_DEFAULT_STORE; // PR_DEFAULT_STORE
sRes.res.resProperty.relop = RELOP_EQ; // is equal to
sRes.res.resProperty.lpProp = &sPropVal; // this property value
// Run the query
// See https://msdn.microsoft.com/en-us/library/office/cc815764.aspx
if (FAILED(hr = HrQueryAllRows(
pStoresTable,
(LPSPropTagArray)&sptEIDCol,
&sRes,
NULL,
0,
&pSRowSet)))
{
ERROR_MSG_W_HR("HrQueryAllRows failed", hr);
goto CLEANUP;
}
// Always check to see if we actually returned some rows
if (pSRowSet && pSRowSet->cRows)
{
// Check to make sure we only returned one default
// We'll use the first one regardless, but let's sound
// a warning anyway.
if (pSRowSet->cRows > 1)
{
WARN("We returned more than on Default store!");
}
// Open the message store
if (FAILED(hr = DoOpenMsgStore(
&pSRowSet->aRow[0].lpProps[EID].Value.bin,
MDB_WRITE,
lppDefaultMDB)))
{
ERROR_MSG_W_HR("DoOpenMsgStore failed.", hr);
goto CLEANUP;
}
}
else
hr = MAPI_E_NOT_FOUND;
//.........这里部分代码省略.........
示例15: openSpecialFolder
/* open special folder */
bool Mapix::openSpecialFolder(CString folderName, SBinary bin, LPMDB msgStore)
{
LPMAPITABLE table = NULL;
LPMAPIFOLDER m_folder= NULL;
ULONG objectType = NULL;
LPSRowSet pRows = NULL;
result = msgStore->OpenEntry(bin.cb, (LPENTRYID)bin.lpb, NULL, MAPI_MODIFY|MAPI_BEST_ACCESS, &objectType, (LPUNKNOWN*)&m_folder);
if(result != S_OK)
{
setError(result);
return 0;
}
else
{
result = m_folder->GetHierarchyTable(NULL, &table);
if(result == S_OK)
{
const int nProperties = 2;
SizedSPropTagArray(nProperties, Column) = {nProperties, {PR_DISPLAY_NAME, PR_ENTRYID}};
result = table->SetColumns((LPSPropTagArray)&Column, 0);
if(result == S_OK)
{
while(table->QueryRows(1,0, &pRows) == S_OK)
{
if(pRows->cRows != 1)
break;
else
{
CString nameOfFolder( pRows->aRow[0].lpProps[0].Value.lpszW);
if(nameOfFolder == folderName)
{
sBin = pRows->aRow[0].lpProps[1].Value.bin;
m_lpInboxMsgStore = msgStore;
m_folder->Release();
table->Release();
pRows = NULL;
return 1;
}
// open enumarate folder
openSpecialFolder(folderName, pRows->aRow[0].lpProps[1].Value.bin, msgStore);
}
}
}
else
{
setError(result);
return 0;
}
}
else
{
setError(result);
return 0;
}
}
return 0;
}