本文整理汇总了C++中LPADRBOOK类的典型用法代码示例。如果您正苦于以下问题:C++ LPADRBOOK类的具体用法?C++ LPADRBOOK怎么用?C++ LPADRBOOK使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPADRBOOK类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetExEmail
BOOL CMAPIEx::GetExEmail(SBinary entryID, CString& strEmail) {
BOOL bResult = FALSE;
#ifndef _WIN32_WCE
if (!m_pSession) return FALSE;
LPADRBOOK pAddressBook;
if (m_pSession->OpenAddressBook(0, NULL, AB_NO_DIALOG, &pAddressBook) == S_OK) {
ULONG ulObjType;
IMAPIProp *pItem = NULL;
if (pAddressBook->OpenEntry(entryID.cb, (ENTRYID *)entryID.lpb, NULL, MAPI_BEST_ACCESS, &ulObjType, (LPUNKNOWN *)&pItem) == S_OK) {
if (ulObjType == MAPI_MAILUSER) {
LPSPropValue pProp;
ULONG ulPropCount;
ULONG p[2] = { 1, PR_SMTP_ADDRESS };
if (pItem->GetProps((LPSPropTagArray)p, CMAPIEx::cm_nMAPICode, &ulPropCount, &pProp) == S_OK) {
strEmail = CMAPIEx::GetValidString(*pProp);
MAPIFreeBuffer(pProp);
bResult = TRUE;
}
}
RELEASE(pItem);
}
RELEASE(pAddressBook);
}
#endif
return bResult;
}
示例2: AddRecipientW
HRESULT AddRecipientW(LPMESSAGE lpMessage,
ULONG ulRecipientType,
LPWSTR szRecipientName){
HRESULT hRes = S_OK;
LPADRLIST lpAdrList = NULL; // ModifyRecips takes LPADRLIST
LPADRBOOK lpAddrBook = NULL;
hRes = HrAllocAdrList(NUM_RECIP_PROPS, &lpAdrList);
if (SUCCEEDED(hRes) && lpAdrList)
{
// Set up the recipient by indicating how many recipients
// and how many properties will be set on each recipient.
lpAdrList->cEntries = 1; // How many recipients.
lpAdrList->aEntries[0].cValues = NUM_RECIP_PROPS; // How many properties per recipient
lpAdrList->aEntries[0].rgPropVals[p_PR_DISPLAY_NAME_W].ulPropTag = PR_DISPLAY_NAME_W;
lpAdrList->aEntries[0].rgPropVals[p_PR_RECIPIENT_TYPE].ulPropTag = PR_RECIPIENT_TYPE;
lpAdrList->aEntries[0].rgPropVals[p_PR_DISPLAY_NAME_W].Value.lpszW = szRecipientName;
lpAdrList->aEntries[0].rgPropVals[p_PR_RECIPIENT_TYPE].Value.l = ulRecipientType;
// If everything goes right, add the new recipient to the message
// object passed into us.
hRes = lpMessage->ModifyRecipients(MODRECIP_ADD, lpAdrList);
}
if (lpAdrList) FreePadrlist(lpAdrList);
if (lpAddrBook) lpAddrBook->Release();
return hRes;
}
示例3: switch
void CBaseDialog::OnNotificationsOff()
{
HRESULT hRes = S_OK;
if (m_ulBaseAdviseConnection && m_lpMapiObjects)
{
switch (m_ulBaseAdviseObjectType)
{
case MAPI_SESSION:
{
LPMAPISESSION lpMAPISession = m_lpMapiObjects->GetSession(); // do not release
if (lpMAPISession) EC_MAPI(lpMAPISession->Unadvise(m_ulBaseAdviseConnection));
break;
}
case MAPI_STORE:
{
LPMDB lpMDB = m_lpMapiObjects->GetMDB(); // do not release
if (lpMDB) EC_MAPI(lpMDB->Unadvise(m_ulBaseAdviseConnection));
break;
}
case MAPI_ADDRBOOK:
{
LPADRBOOK lpAB = m_lpMapiObjects->GetAddrBook(false); // do not release
if (lpAB) EC_MAPI(lpAB->Unadvise(m_ulBaseAdviseConnection));
break;
}
}
}
if (m_lpBaseAdviseSink) m_lpBaseAdviseSink->Release();
m_lpBaseAdviseSink = NULL;
m_ulBaseAdviseObjectType = NULL;
m_ulBaseAdviseConnection = NULL;
} // CBaseDialog::OnNotificationsOff
示例4: AddRecipient
_Check_return_ HRESULT AddRecipient(
_In_ LPMAPISESSION lpMAPISession,
_In_ LPMESSAGE lpMessage,
_In_z_ LPCTSTR szName,
ULONG ulRecipientType)
{
HRESULT hRes = S_OK;
LPADRLIST lpAdrList = NULL; // ModifyRecips takes LPADRLIST
LPADRBOOK lpAddrBook = NULL;
enum
{
NAME,
RECIP,
NUM_RECIP_PROPS
};
if (!lpMessage || !lpMAPISession) return MAPI_E_INVALID_PARAMETER;
EC_MAPI(lpMAPISession->OpenAddressBook(
NULL,
NULL,
NULL,
&lpAddrBook));
EC_MAPI(HrAllocAdrList(NUM_RECIP_PROPS, &lpAdrList));
if (lpAdrList)
{
// Setup the One Time recipient by indicating how many recipients
// and how many properties will be set on each recipient.
lpAdrList->cEntries = 1; // How many recipients.
lpAdrList->aEntries[0].cValues = NUM_RECIP_PROPS; // How many properties per recipient
// Set the SPropValue members == the desired values.
lpAdrList->aEntries[0].rgPropVals[NAME].ulPropTag = PR_DISPLAY_NAME;
lpAdrList->aEntries[0].rgPropVals[NAME].Value.LPSZ = (LPTSTR)szName;
lpAdrList->aEntries[0].rgPropVals[RECIP].ulPropTag = PR_RECIPIENT_TYPE;
lpAdrList->aEntries[0].rgPropVals[RECIP].Value.l = ulRecipientType;
EC_MAPI(lpAddrBook->ResolveName(
0L,
fMapiUnicode,
NULL,
lpAdrList));
// If everything goes right, add the new recipient to the message
// object passed into us.
EC_MAPI(lpMessage->ModifyRecipients(MODRECIP_ADD, lpAdrList));
EC_MAPI(lpMessage->SaveChanges(KEEP_OPEN_READWRITE));
}
if (lpAdrList) FreePadrlist(lpAdrList);
if (lpAddrBook) lpAddrBook->Release();
return hRes;
} // AddRecipient
示例5: AddRecipientA
HRESULT AddRecipientA(LPMAPISESSION lpMAPISession,
LPMESSAGE lpMessage,
ULONG ulRecipientType,
LPSTR szRecipientName)
{
HRESULT hRes = S_OK;
LPADRLIST lpAdrList = NULL; // ModifyRecips takes LPADRLIST
LPADRBOOK lpAddrBook = NULL;
if (!lpMessage || !lpMAPISession) return MAPI_E_INVALID_PARAMETER;
hRes = lpMAPISession->OpenAddressBook(
NULL,
NULL,
NULL,
&lpAddrBook);
if (SUCCEEDED(hRes) && lpAddrBook)
{
hRes = HrAllocAdrList(NUM_RECIP_PROPS, &lpAdrList);
if (SUCCEEDED(hRes) && lpAdrList)
{
// Set up the recipient by indicating how many recipients
// and how many properties will be set on each recipient.
lpAdrList->cEntries = 1; // How many recipients.
lpAdrList->aEntries[0].cValues = NUM_RECIP_PROPS; // How many properties per recipient
lpAdrList->aEntries[0].rgPropVals[p_PR_DISPLAY_NAME_W].ulPropTag = PR_DISPLAY_NAME_A;
lpAdrList->aEntries[0].rgPropVals[p_PR_RECIPIENT_TYPE].ulPropTag = PR_RECIPIENT_TYPE;
lpAdrList->aEntries[0].rgPropVals[p_PR_DISPLAY_NAME_W].Value.lpszA = szRecipientName;
lpAdrList->aEntries[0].rgPropVals[p_PR_RECIPIENT_TYPE].Value.l = ulRecipientType;
hRes = lpAddrBook->ResolveName(
0L,
MAPI_UNICODE,
NULL,
lpAdrList);
if (SUCCEEDED(hRes))
{
// If everything goes right, add the new recipient to the message
// object passed into us.
hRes = lpMessage->ModifyRecipients(MODRECIP_ADD, lpAdrList);
}
}
}
if (lpAdrList) FreePadrlist(lpAdrList);
if (lpAddrBook) lpAddrBook->Release();
return hRes;
}
示例6: FreeWAB
void FreeWAB(HINSTANCE hWAB,
LPADRBOOK pAdrBook,
LPWABOBJECT pWABObject,
AdrBookTable *pTable,
UINT nNumEntries)
{
if (pTable && nNumEntries)
{
for (UINT i=0; i<nNumEntries; i++)
{
if (pTable[i].szName)
free(pTable[i].szName);
if (pTable[i].szEmail)
free(pTable[i].szEmail);
}
free(pTable);
}
if(pAdrBook)
pAdrBook->Release();
if(pWABObject)
pWABObject->Release();
if(hWAB)
FreeLibrary(hWAB);
return;
}
示例7: SessionLogOn
bool COLAddrBook::SessionLogOn(ULONG hWnd, LPCTSTR profile, LPCTSTR pswd, ULONG flags)
{
bool bResult = false;
LPMAPISESSION pSession = NULL;
HRESULT hr = g_pMAPIEDK->pMAPILogonEx(hWnd, (LPTSTR)profile, (LPTSTR)pswd, flags, &pSession);
if (pSession)
{
LPADRBOOK pAddrBook = NULL;
if (SUCCEEDED(pSession->OpenAddressBook(NULL, NULL, AB_NO_DIALOG, &pAddrBook)))
{
m_initRef->SetAddrBook(pAddrBook);
// открываем корневой каталог
ULONG ulObjType = 0;
LPUNKNOWN pUnk = NULL;
if (SUCCEEDED(pAddrBook->OpenEntry(0, NULL, NULL, MAPI_BEST_ACCESS, &ulObjType, &pUnk)))
{
if (MAPI_ABCONT == ulObjType)
{
LPABCONT pContainer = NULL;
m_pABCont = (LPABCONT)pUnk;
m_pABCont->AddRef();
bResult = true;
}
}
if (pUnk)
pUnk->Release();
}
if (pAddrBook)
pAddrBook->Release();
}
if (pSession)
pSession->Release();
return bResult;
}
示例8: ShowAddressBook
// Shows the default Address Book dialog, return FALSE on failure, IDOK or IDCANCEL on success
// I force narrow strings here because it for some reason doesn't work in UNICODE
int CMAPIEx::ShowAddressBook(LPADRLIST& pAddressList, LPCTSTR szCaption)
{
#ifndef _WIN32_WCE
if(!m_pSession) return FALSE;
LPADRBOOK pAddressBook;
if(m_pSession->OpenAddressBook(0, NULL, 0, &pAddressBook)==S_OK)
{
pAddressList=NULL;
char* lppszDestTitles[]={ "To" };
ULONG lpulDestComps[]={ MAPI_TO };
ADRPARM adrparm;
memset(&adrparm, 0,sizeof(ADRPARM));
adrparm.ulFlags=DIALOG_MODAL | AB_RESOLVE;
adrparm.lpszCaption=(LPTSTR)szCaption;
#ifdef UNICODE
if(szCaption)
{
char szNarrowCaption[256];
WideCharToMultiByte(CP_ACP, 0, szCaption,-1, szNarrowCaption,255, NULL, NULL);
adrparm.lpszCaption=(LPTSTR)szNarrowCaption;
}
#endif
adrparm.cDestFields = 1;
adrparm.lppszDestTitles=(LPTSTR*)lppszDestTitles;
adrparm.lpulDestComps=lpulDestComps;
HWND hDesktop=::GetDesktopWindow();
HRESULT hr=pAddressBook->Address((ULONG_PTR*)&hDesktop, &adrparm, &pAddressList);
RELEASE(pAddressBook);
if(hr==S_OK) return IDOK;
if(hr==MAPI_E_USER_CANCEL) return IDCANCEL;
}
#endif
return FALSE;
}
示例9: ImportWAB
void CProcessor::ImportWAB()
{
HINSTANCE hinstLib;
HRESULT hRes;
LPADRBOOK lpAdrBook;
LPWABOBJECT lpWABObject;
DWORD Reserved2 = NULL;
fWABOpen procWABOpen;
{
TCHAR szWABDllPath[MAX_PATH];
DWORD dwType = 0;
ULONG cbData = sizeof(szWABDllPath);
HKEY hKey = NULL;
*szWABDllPath = '\0';
// First we look under the default WAB DLL path location in the
// Registry.
// WAB_DLL_PATH_KEY is defined in wabapi.h
//
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, WAB_DLL_PATH_KEY, 0, KEY_READ, &hKey))
RegQueryValueEx( hKey, "", NULL, &dwType, (LPBYTE) szWABDllPath, &cbData);
if(hKey) RegCloseKey(hKey);
// if the Registry came up blank, we do a loadlibrary on the wab32.dll
// WAB_DLL_NAME is defined in wabapi.h
//
hinstLib = LoadLibrary( (lstrlen(szWABDllPath)) ? szWABDllPath : WAB_DLL_NAME );
}
if (hinstLib != NULL)
{
procWABOpen = (fWABOpen) GetProcAddress(hinstLib, "WABOpen");
if (procWABOpen != NULL)
{
hRes = (procWABOpen)(&lpAdrBook,&lpWABObject,NULL,Reserved2); // WABOpen
_ASSERTE(hRes == S_OK);
if (hRes != S_OK) return;
ULONG lpcbEntryID;
ENTRYID *lpEntryID;
hRes = lpAdrBook->GetPAB(
&lpcbEntryID,
&lpEntryID
);
_ASSERTE(hRes == S_OK);
if (hRes != S_OK) return;
ULONG ulFlags = MAPI_BEST_ACCESS;
ULONG ulObjType = NULL;
LPUNKNOWN lpUnk = NULL;
hRes = lpAdrBook->OpenEntry(
lpcbEntryID,
lpEntryID,
NULL,
ulFlags,
&ulObjType,
&lpUnk
);
ulFlags = NULL;
//IABTable *lpTable;
if (ulObjType == MAPI_ABCONT)
{
IABContainer *lpContainer = static_cast <IABContainer *>(lpUnk);
LPMAPITABLE lpTable = NULL;
hRes = lpContainer->GetContentsTable(
ulFlags,
&lpTable
);
_ASSERT(lpTable);
ULONG ulRows, ulFound = 0, ulExisted = 0;
hRes = lpTable->GetRowCount(0,&ulRows);
_ASSERTE(hRes == S_OK);
SRowSet *lpRows;
hRes = lpTable->SetColumns( (LPSPropTagArray)&ptaEid, 0 );
hRes = lpTable->QueryRows(
ulRows, // Get all Rows
0,
&lpRows
);
for(ULONG i=0;i<lpRows->cRows;i++)
{
bool bBirthdayProcessed = false;
CBirthday* pbd = new CBirthday;
SRow *lpRow = &lpRows->aRow[i];
for(ULONG j=0;j<lpRow->cValues;j++)
{
SPropValue *lpProp = &lpRow->lpProps[j];
if(lpProp->ulPropTag == PR_BIRTHDAY)
//.........这里部分代码省略.........
示例10: SetAddressListSearchOrder
// Set address list search order
STDMETHODIMP SetAddressListSearchOrder(IMAPISession &Session, const list<string> &SearchList) {
HRESULT hr;
LPADRBOOK lpAddrBook = NULL;
LPVOID tempLink;
SRowSet *NewSRowSet = NULL;
// New SRow list of search path
list<SRow> NewSRowList;
// Corresponding SPropValue's for SRow.lpProps in NewSRowList
list<SPropValue> NewSPropList;
// Setup struct specifying MAPI fields to query
enum {
abPR_ENTRYID, // Field index for ENTRYID
abPR_DISPLAY_NAME_A, // Field index for display name
abNUM_COLS // Automatically set to number of fields
};
static SizedSPropTagArray(abNUM_COLS, abCols) = {
abNUM_COLS, // Num fields to get (2)
PR_ENTRYID, // Get ENTRYID struct
PR_DISPLAY_NAME_A // Get display name
};
// Open address book
hr = Session.OpenAddressBook(NULL, NULL, NULL, &lpAddrBook);
if (FAILED(hr)) {
cerr << "Error getting MAPI Address book." << endl;
goto Exit;
}
TraceSearchPath(*lpAddrBook);
ULONG ulObjType;
LPMAPICONTAINER pIABRoot = NULL;
hr = lpAddrBook->OpenEntry(0, NULL, NULL, 0, &ulObjType, (LPUNKNOWN *)&pIABRoot);
if (FAILED(hr) || ulObjType != MAPI_ABCONT) {
cerr << "Error opening MAPI Address book root entry." << endl;
if (SUCCEEDED(hr)) hr = E_UNEXPECTED;
goto Cleanup;
}
// Setup MAPI memory allocation link
MAPIAllocateBuffer(0, &tempLink);
// Query MAPI for all address lists
LPMAPITABLE pHTable = NULL;
hr = pIABRoot->GetHierarchyTable(CONVENIENT_DEPTH, &pHTable);
if (FAILED(hr)) {
cerr << "Error obtaining MAPI address list hierarchy." << endl;
goto Cleanup;
}
LPSRowSet pQueryRows = NULL;
hr = HrQueryAllRows(pHTable, (LPSPropTagArray)&abCols, NULL, NULL, 0, &pQueryRows);
if (FAILED(hr)) {
cerr << "Error getting MAPI address lists." << endl;
goto Cleanup;
}
// Cross reference pQueryRows with SearchList for matches
for (list<string>::const_iterator SearchListIter = SearchList.begin(); SearchListIter != SearchList.end(); SearchListIter++) {
const string &SearchName = *SearchListIter;
// Is SearchName in the pQueryRows list?
for (ULONG i = 0; i < pQueryRows->cRows && pQueryRows->aRow[i].lpProps[abPR_DISPLAY_NAME_A].ulPropTag == PR_DISPLAY_NAME_A; i++) {
SRow &QueryRow = pQueryRows->aRow[i];
string ContainerName = QueryRow.lpProps[abPR_DISPLAY_NAME_A].Value.lpszA;
if (ContainerName == SearchName) {
// Found a match!
cout << "Adding address list search path: " << SearchName << endl;
// Build SRow/SPropValue structs
// Assumptions: SRow contains 1 SPropValue of type SBinary
SPropValue TmpSPropValue = { QueryRow.lpProps[0].ulPropTag, QueryRow.lpProps[0].dwAlignPad };
NewSPropList.push_back(TmpSPropValue);
SPropValue &NewSPropValue = NewSPropList.back();
SRow TmpSRow = { QueryRow.ulAdrEntryPad, 1, &NewSPropValue };
NewSRowList.push_back(TmpSRow);
SRow &NewSRow = NewSRowList.back();
// Safely copy binary portion of SPropValue
hr = CopySBinary(
NewSRow.lpProps[0].Value.bin,
QueryRow.lpProps[0].Value.bin,
tempLink);
if (FAILED(hr)) {
cerr << "Error while building MAPI data." << endl;
goto Cleanup;
}
// break out of inner pQueryRows loop and continue to next in SearchList
break;
}
} // for (i in pQueryRows)
} // for (SearchList)
//.........这里部分代码省略.........
示例11: TSTRING
/// <summary>
/// <para name='Name'>ResolveDisplayName</para>
/// <para name='Purpose'>Get an email address from a Display Name</para>
/// </summary>
/// <param name='szName'>Display Name to resolve</param>
/// <param name='szEmailAddress'>[out] Returned email address</param>
/// <returns>HRESULT</returns>
/// <remarks>
/// <para name='Notes'></para>
/// <para name='Author'>Kenn Guilstorf</para>
/// <para name='LastModified'>28Jan2016</para>
/// </remarks>
STDMETHODIMP ZybraxiSoft::CMailbox::ResolveDisplayName(TSTRING szName, TSTRING &szEmailAddress)
{
HRESULT hr = S_OK;
LPADRBOOK lpAdrBook = NULL;
LPADRLIST lpAdrList = NULL;
TSTRING szEX = TSTRING(_T("EX"));
bool isExchange = false;
enum
{
prDISPLAY_NAME,
NUM_PROPS
};
// Check to make sure we have something in szName
if (szName.empty() || szName.size() <= 0)
{
hr = MAPI_E_INVALID_PARAMETER;
goto EXIT;
}
// Log what we're trying to resolve
m_log << output::both << level::Informational <<
"Attempting to resolve '" << szName.c_str() << "'" << endl;
// Open the address book
// See: https://msdn.microsoft.com/en-us/library/office/cc815381.aspx
if (SUCCEEDED(hr = m_lpSession->OpenAddressBook(
NULL, // ulUIParam [may be NULL]
NULL, // lpInterface [may be NULL; returns IAddrBook:IMAPIProp]
NULL, // ulFlags [NULL means no flags]
&lpAdrBook))) // lppAdrBook [out]
{
// Allocate the address list
// Note: I like to use 'this' so I know which functions I'm responsible
// for if I ever have to work on this...
if (SUCCEEDED(hr = this->AllocAdrList(
NUM_PROPS,
&lpAdrList)))
{
// Even though we succeeded, do a check to make sure we have
// an address list
if (lpAdrList)
{
lpAdrList->cEntries = 1; // only looking for 1 entry
lpAdrList->aEntries[0].cValues = NUM_PROPS; // Number of props
// Set the SPropValue to whom we're looking for
lpAdrList->aEntries[0].rgPropVals[prDISPLAY_NAME].ulPropTag =
PR_DISPLAY_NAME;
lpAdrList->aEntries[0].rgPropVals[prDISPLAY_NAME].Value.LPSZ =
(LPTSTR)szName.c_str();
// Let's try to resolve the name now
if (SUCCEEDED(hr = lpAdrBook->ResolveName(
0L,
MAPI_UNICODE,
NULL,
lpAdrList)))
{
m_log << output::both << level::Informational <<
"Resolve name yielded " <<
lpAdrList->aEntries[0].cValues <<
" properties." << endl;
for (UINT i = 0; i < lpAdrList->aEntries[0].cValues; i++)
{
// Store the property so I don't have to type so much...
SPropValue spvCurrent = lpAdrList->aEntries[0].rgPropVals[i];
m_log << output::both << level::Informational <<
"Found Property '0x" <<
setfill(_T('0')) << setw(8) << setbase(16) <<
spvCurrent.ulPropTag << "'";
switch (spvCurrent.ulPropTag)
{
case PR_ADDRTYPE:
if (szEX.compare(spvCurrent.Value.LPSZ) == 0)
isExchange = true;
break;
case PR_DISPLAY_NAME:
m_log << ": " << spvCurrent.Value.LPSZ;
break;
case PR_EMAIL_ADDRESS:
m_log << ": " << spvCurrent.Value.LPSZ;
szEmailAddress = TSTRING(spvCurrent.Value.LPSZ);
break;
//.........这里部分代码省略.........
示例12: ResolveAddressList
// Resolve address list name to ENTRYID
// Memory is allocated through MAPIAllocateBuffer using pAllocLink
STDMETHODIMP ResolveAddressList(IMAPISession &Session, const string &AddressList, LPVOID pAllocLink, ULONG *cbEntry, LPENTRYID *Entry) {
HRESULT hr = S_OK;
// Setup struct specifying MAPI fields to query
enum {
abPR_ENTRYID, // Field index for ENTRYID
abPR_DISPLAY_NAME_A, // Field index for display name
abNUM_COLS // Automatically set to number of fields
};
static SizedSPropTagArray(abNUM_COLS, abCols) = {
abNUM_COLS, // Num fields to get (2)
PR_ENTRYID, // Get ENTRYID struct
PR_DISPLAY_NAME_A // Get display name
};
// Open address book
LPADRBOOK lpAddrBook;
hr = Session.OpenAddressBook(NULL, NULL, NULL, &lpAddrBook);
if (FAILED(hr)) {
cerr << "Error getting MAPI Address book." << endl;
goto Exit;
}
ULONG ulObjType;
LPMAPICONTAINER pIABRoot = NULL;
hr = lpAddrBook->OpenEntry(0, NULL, NULL, 0, &ulObjType, (LPUNKNOWN *)&pIABRoot);
if (FAILED(hr) || ulObjType != MAPI_ABCONT) {
cerr << "Error opening MAPI Address book root entry." << endl;
if (SUCCEEDED(hr)) hr = E_UNEXPECTED;
goto Cleanup;
}
// Query MAPI for all address lists
LPMAPITABLE pHTable = NULL;
hr = pIABRoot->GetHierarchyTable(CONVENIENT_DEPTH, &pHTable);
if (FAILED(hr)) {
cerr << "Error obtaining MAPI address list hierarchy." << endl;
goto Cleanup;
}
LPSRowSet pQueryRows = NULL;
hr = HrQueryAllRows(pHTable, (LPSPropTagArray)&abCols, NULL, NULL, 0, &pQueryRows);
if (FAILED(hr)) {
cerr << "Error getting MAPI address lists." << endl;
goto Cleanup;
}
// Is AddressList in the pQueryRows list?
for (ULONG i = 0; i < pQueryRows->cRows && pQueryRows->aRow[i].lpProps[abPR_DISPLAY_NAME_A].ulPropTag == PR_DISPLAY_NAME_A; i++) {
SRow &QueryRow = pQueryRows->aRow[i];
string ContainerName = QueryRow.lpProps[abPR_DISPLAY_NAME_A].Value.lpszA;
if (ContainerName == AddressList) {
// Found a match!
// Build ENTRYID struct
ULONG cbNewEntryID = QueryRow.lpProps[abPR_ENTRYID].Value.bin.cb;
LPENTRYID lpNewEntryID;
MAPIAllocateMore(cbNewEntryID, pAllocLink, (LPVOID *)&lpNewEntryID);
memcpy(lpNewEntryID, QueryRow.lpProps[abPR_ENTRYID].Value.bin.lpb, cbNewEntryID);
// Set return values
*cbEntry = cbNewEntryID;
*Entry = lpNewEntryID;
// Break out
break;
}
}
Cleanup:
if (lpAddrBook) lpAddrBook->Release();
Exit:
return hr;
}
示例13: OnCompareEntryIDs
void CBaseDialog::OnCompareEntryIDs()
{
HRESULT hRes = S_OK;
if (!m_lpMapiObjects) return;
LPMDB lpMDB = m_lpMapiObjects->GetMDB(); // do not release
LPMAPISESSION lpMAPISession = m_lpMapiObjects->GetSession(); // do not release
LPADRBOOK lpAB = m_lpMapiObjects->GetAddrBook(false); // do not release
CEditor MyEIDs(
this,
IDS_COMPAREEIDS,
IDS_COMPAREEIDSPROMPTS,
4,
CEDITOR_BUTTON_OK | CEDITOR_BUTTON_CANCEL);
MyEIDs.InitPane(0, CreateSingleLinePane(IDS_EID1, NULL, false));
MyEIDs.InitPane(1, CreateSingleLinePane(IDS_EID2, NULL, false));
UINT uidDropDown[] = {
IDS_DDMESSAGESTORE,
IDS_DDSESSION,
IDS_DDADDRESSBOOK
};
MyEIDs.InitPane(2, CreateDropDownPane(IDS_OBJECTFORCOMPAREEID, _countof(uidDropDown), uidDropDown, true));
MyEIDs.InitPane(3, CreateCheckPane(IDS_EIDBASE64ENCODED, false, false));
WC_H(MyEIDs.DisplayDialog());
if (S_OK != hRes) return;
if ((0 == MyEIDs.GetDropDown(2) && !lpMDB) ||
(1 == MyEIDs.GetDropDown(2) && !lpMAPISession) ||
(2 == MyEIDs.GetDropDown(2) && !lpAB))
{
ErrDialog(__FILE__, __LINE__, IDS_EDCOMPAREEID);
return;
}
// Get the entry IDs as a binary
LPENTRYID lpEntryID1 = NULL;
size_t cbBin1 = NULL;
EC_H(MyEIDs.GetEntryID(0, MyEIDs.GetCheck(3), &cbBin1, &lpEntryID1));
LPENTRYID lpEntryID2 = NULL;
size_t cbBin2 = NULL;
EC_H(MyEIDs.GetEntryID(1, MyEIDs.GetCheck(3), &cbBin2, &lpEntryID2));
ULONG ulResult = NULL;
switch (MyEIDs.GetDropDown(2))
{
case 0: // Message Store
EC_MAPI(lpMDB->CompareEntryIDs((ULONG)cbBin1, lpEntryID1, (ULONG)cbBin2, lpEntryID2, NULL, &ulResult));
break;
case 1: // Session
EC_MAPI(lpMAPISession->CompareEntryIDs((ULONG)cbBin1, lpEntryID1, (ULONG)cbBin2, lpEntryID2, NULL, &ulResult));
break;
case 2: // Address Book
EC_MAPI(lpAB->CompareEntryIDs((ULONG)cbBin1, lpEntryID1, (ULONG)cbBin2, lpEntryID2, NULL, &ulResult));
break;
}
if (SUCCEEDED(hRes))
{
CString szRet;
CString szResult;
EC_B(szResult.LoadString(ulResult ? IDS_TRUE : IDS_FALSE));
szRet.FormatMessage(IDS_COMPAREEIDBOOL, ulResult, szResult);
CEditor Result(
this,
IDS_COMPAREEIDSRESULT,
NULL,
(ULONG)0,
CEDITOR_BUTTON_OK);
Result.SetPromptPostFix(szRet);
(void)Result.DisplayDialog();
}
delete[] lpEntryID2;
delete[] lpEntryID1;
} // CBaseDialog::OnCompareEntryIDs
示例14: ManualResolve
// Manually resolve a name in the address book and add it to the message
_Check_return_ HRESULT ManualResolve(
_In_ LPMAPISESSION lpMAPISession,
_In_ LPMESSAGE lpMessage,
_In_z_ LPCTSTR szName,
ULONG PropTagToCompare)
{
HRESULT hRes = S_OK;
ULONG ulObjType = 0;
LPADRBOOK lpAdrBook = NULL;
LPSRowSet lpABRow = NULL;
LPMAPITABLE lpABContainerTable = NULL;
LPADRLIST lpAdrList = NULL;
LPABCONT lpABContainer = NULL;
LPMAPITABLE pTable = NULL;
LPSPropValue lpFoundRow = NULL;
enum
{
abcPR_ENTRYID,
abcPR_DISPLAY_NAME,
abcNUM_COLS
};
static const SizedSPropTagArray(abcNUM_COLS, abcCols) =
{
abcNUM_COLS,
PR_ENTRYID,
PR_DISPLAY_NAME,
};
enum
{
abPR_ENTRYID,
abPR_DISPLAY_NAME,
abPR_RECIPIENT_TYPE,
abPR_ADDRTYPE,
abPR_DISPLAY_TYPE,
abPropTagToCompare,
abNUM_COLS
};
if (!lpMAPISession) return MAPI_E_INVALID_PARAMETER;
DebugPrint(DBGGeneric, _T("ManualResolve: Asked to resolve \"%s\"\n"), szName);
EC_MAPI(lpMAPISession->OpenAddressBook(
NULL,
NULL,
NULL,
&lpAdrBook));
EC_H(GetABContainerTable(lpAdrBook, &lpABContainerTable));
if (lpABContainerTable)
{
// Restrict the table to the properties that we are interested in.
EC_MAPI(lpABContainerTable->SetColumns((LPSPropTagArray)&abcCols, TBL_BATCH));
if (!FAILED(hRes)) for (;;)
{
hRes = S_OK;
FreeProws(lpABRow);
lpABRow = NULL;
EC_MAPI(lpABContainerTable->QueryRows(
1,
NULL,
&lpABRow));
if (FAILED(hRes) || !lpABRow || (lpABRow && !lpABRow->cRows)) break;
// From this point forward, consider any error an error with the current address book container, so just continue and try the next one.
if (PR_ENTRYID == lpABRow->aRow->lpProps[abcPR_ENTRYID].ulPropTag)
{
DebugPrint(DBGGeneric, _T("ManualResolve: Searching this container\n"));
DebugPrintBinary(DBGGeneric, &lpABRow->aRow->lpProps[abcPR_ENTRYID].Value.bin);
if (lpABContainer) lpABContainer->Release();
lpABContainer = NULL;
EC_H(CallOpenEntry(
NULL,
lpAdrBook,
NULL,
NULL,
lpABRow->aRow->lpProps[abcPR_ENTRYID].Value.bin.cb,
(ENTRYID*)lpABRow->aRow->lpProps[abcPR_ENTRYID].Value.bin.lpb,
NULL,
NULL,
&ulObjType,
(LPUNKNOWN*)&lpABContainer));
if (!lpABContainer) continue;
DebugPrint(DBGGeneric, _T("ManualResolve: Object opened as 0x%X\n"), ulObjType);
if (lpABContainer && ulObjType == MAPI_ABCONT)
{
if (pTable) pTable->Release();
pTable = NULL;
WC_MAPI(lpABContainer->GetContentsTable(fMapiUnicode, &pTable));
if (!pTable)
//.........这里部分代码省略.........
示例15: ReadWAB
BOOL ReadWAB(LPADRBOOK pAdrBook,
LPWABOBJECT pWABObject,
AdrBookTable **ppTable,
UINT *pNumEntries)
{
ULONG ulObjType = 0;
LPMAPITABLE lpAB = NULL;
LPTSTR * lppszArray=NULL;
ULONG cRows = 0;
LPSRowSet lpRow = NULL;
LPSRowSet lpRowAB = NULL;
LPABCONT lpContainer = NULL;
int cNumRows = 0;
int nRows=0;
int nCount = 0;
HRESULT hr = E_FAIL;
ULONG lpcbEID;
LPENTRYID lpEID = NULL;
// Get the entryid of the root PAB container
//
hr = pAdrBook->GetPAB( &lpcbEID, &lpEID);
ulObjType = 0;
// Open the root PAB container
// This is where all the WAB contents reside
//
hr = pAdrBook->OpenEntry(lpcbEID,
(LPENTRYID)lpEID,
NULL,
0,
&ulObjType,
(LPUNKNOWN *)&lpContainer);
pWABObject->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;
// 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 szName = lpRowAB->aRow[0].lpProps[ieidPR_DISPLAY_NAME].Value.lpszA;
LPTSTR szEmail = NULL;
LPENTRYID lpEID = (LPENTRYID) lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.lpb;
ULONG cbEID = lpRowAB->aRow[0].lpProps[ieidPR_ENTRYID].Value.bin.cb;
LPMAILUSER pMailUser = NULL;
ULONG ulObjType = 0;
ULONG ulValues;
LPSPropValue lpPropArray;
*ppTable = (AdrBookTable *) realloc(*ppTable,
sizeof(AdrBookTable) * (nCount+1));
(*ppTable)[nCount].szName =
//.........这里部分代码省略.........