哪位知道任何在Outlook Express上编程,读取里边的内容如Email文件夹 Email地址标题等,我知道在Outlook上有公共的公开的接口,不知在Outlook Express上有没有,或用其他的什么方式可以做到???

解决方案 »

  1.   

    MAPI
    Subject Re: How can I import the addresses from Outlook Express to my program  
    Category Misc  
    Posted by alanr on 6/26/01 at 10:55 am   
    Rating 9 (6 votes) 
    Some of this code is EXTREMELY complicated to say the very least. Good luck.You will need to include:
    #include "mapix.h"#include "addrlkup.h"First call the GETMSExchangeUSers() function seen below:void CMAPITestDlg::GetMSExchangeUsers(CStringList &NameList){ CString cst; HRESULT hr = ::MAPIInitialize(NULL); ASSERT(S_OK == hr); LPMAPISESSION pSession = NULL; hr = ::MAPILogonEx(0, NULL, NULL, MAPI_LOGON_UI | MAPI_ALLOW_OTHERS | MAPI_EXTENDED, &pSession); ASSERT(SUCCEEDED(hr)); LPADRBOOK lpAdrBook = NULL; hr = pSession->OpenAddressBook(0, 0, MAPI_ACCESS_MODIFY, &lpAdrBook); ASSERT(SUCCEEDED(hr)); ULONG cbeid = 0; LPENTRYID peid = NULL; hr = HrFindExchangeGlobalAddressList(lpAdrBook, &cbeid, &peid); if (SUCCEEDED(hr)) { ULONG openFlags = MAPI_BEST_ACCESS; hr = lpAdrBook->OpenEntry(cbeid, peid, NULL, openFlags, &ulObjType, (LPUNKNOWN *)&dlpPABEntry); if (hr ==S_OK) { SizedSPropTagArray(2, sptStoTbl) = {2, {PR_DISPLAY_NAME, PR_EMS_AB_PROXY_ADDRESSES}}; if (HR_SUCCEEDED(((LPABCONT)dlpPABEntry)->GetContentsTable(0L, &lppabcont))) { if (HR_SUCCEEDED(lppabcont->SetColumns((LPSPropTagArray)&sptStoTbl, TBL_BATCH))) { hr = ((LPMAPITABLE)lppabcont)->GetRowCount(0, &lpulCount); int x = 0; int iTotNum = lpulCount; int num_iterations = (lpulCount / 50); int num_left = (lpulCount - (num_iterations * 50)); m_Count = lpulCount; while (x < num_iterations) { if (HR_SUCCEEDED(((LPMAPITABLE)lppabcont)->QueryRows((LONG)lpulCount, 0, &lprws))) { for (int i = 0; i < (int)(*lprws).cRows; i++) { CString stro, addr, ListElement; stro.Format("%s", lprws->aRow.lpProps[0].Value.lpszA); ListElement = stro; if (IsItValid(stro) == 1) { ++cntr; ++m_MostRecentCount; cst.Format("%d", cntr); NameList.AddTail(ListElement); CString ice; ice.Format("%d of %d", cntr, iTotNum); SetDlgItemText(IDC_NUM, ice); } } } ++x; } if (HR_SUCCEEDED(((LPMAPITABLE)lppabcont)->QueryRows((LONG)lpulCount, 0, &lprws))) { for (int i = 0; i < num_left; i++) { CString stro, addr, ListElement; stro.Format("%s", lprws->aRow.lpProps[0].Value.lpszA); ListElement = stro; if (IsItValid(stro) == 1) { ++cntr; ++m_MostRecentCount; cst.Format("%d", cntr); NameList.AddTail(ListElement); } } } } } } } else { AfxMessageBox("Error..."); } if (peid) { ::MAPIFreeBuffer(peid); } if (lpAdrBook) { lpAdrBook->Release(); } ::MAPIUninitialize();}
    then call GetEMailWithUserNameAndList() with the name and user list as parameters: in the function below:CString CMAPITestDlg::GetEMailWithUserNameAndList(CString User, CStringList &UserList){ CString Name = User;  CString Address; HRESULT hr; LPADRBOOK       lpAddrbk = NULL; LPADRLIST       pAdrList = NULL; ULONG           i, j; SBinary         sBin; LPMAILUSER     pMailUser = NULL; ULONG           cValues = 0; LPSPropValue    lpPropValue = NULL; char            szUserEmailAddress[50]; LPMAPISESSION pSession = NULL; hr = ::MAPILogonEx(0, NULL, NULL, MAPI_LOGON_UI | MAPI_ALLOW_OTHERS | MAPI_EXTENDED, &pSession); if (hr == S_OK) { SizedSPropTagArray(1, sptOneItem) = { 1, PR_EMS_AB_PROXY_ADDRESSES};   hr = pSession->OpenAddressBook(0, NULL, 0, &lpAddrbk);     if (hr == S_OK) { lpAddrbk->Address(NULL, NULL, &pAdrList); hr = MAPIAllocateBuffer(CbNewSRowSet(1),(LPVOID*) &pAdrList);     if (hr == S_OK) { ZeroMemory(pAdrList, CbNewSRowSet(1)); hr = MAPIAllocateBuffer(7 * sizeof(SPropValue), (LPVOID FAR *)&(pAdrList->aEntries[0].rgPropVals)); ZeroMemory(pAdrList->aEntries[0].rgPropVals, 7 * sizeof(SPropValue)); pAdrList->cEntries = 1; pAdrList->aEntries[0].cValues = 2L; pAdrList->aEntries[0].rgPropVals[0].ulPropTag = PR_DISPLAY_NAME; char * ptrName = Name.GetBuffer(strlen(Name)); pAdrList->aEntries[0].rgPropVals[0].Value.lpszA = ptrName; pAdrList->aEntries[0].rgPropVals[1].ulPropTag = PR_ADDRTYPE; pAdrList->aEntries[0].rgPropVals[1].Value.lpszA = "SMTP"; hr = lpAddrbk->ResolveName(0L, 0L, NULL, pAdrList); for (i = 0; i < 7; ++i) { if (pAdrList->aEntries[0].rgPropVals[0].ulPropTag == PR_ENTRYID)  { sBin.cb = pAdrList->aEntries[0].rgPropVals.Value.bin.cb; sBin.lpb = pAdrList->aEntries[0].rgPropVals.Value.bin.lpb; hr = lpAddrbk->OpenEntry(sBin.cb, (LPENTRYID)sBin.lpb,  NULL, 0, &ulObjType, (LPUNKNOWN*)&pMailUser); if (FAILED(hr)) { break; } hr = pMailUser->GetProps((LPSPropTagArray)&sptOneItem, 0, &cValues, &lpPropValue); if (hr & MAPI_W_ERRORS_RETURNED) { break; } if (HR_FAILED(hr)) { break; }           for (j = 0; j < lpPropValue->Value.MVszA.cValues; j++) { if (!strncmp(lpPropValue->Value.MVszA.lppszA[j],"SMTP",4)) { strcpy(szUserEmailAddress, lpPropValue->Value.MVszA.lppszA[j]+5); Address = szUserEmailAddress; if ((Address.Find("@") != -1)) { return Address; } } } } } } } } return Address;}
    Best of luck... I spent a great deal of time on this code, a good ratuing would be [email protected]
    http://envelopebudget.com >>>>>How to read Outlook Express *.dbx files<<<<<http://www.djpate.freeserve.co.uk/oexpress2.zip
      

  2.   

    a good source of Outlook Express info can be found here:
    http://www.tomsterdam.com
      

  3.   

    首先感想 masterz(MS MVP) 和 kingzai(),我粗劣浏览了一下,确实对我是有帮助的,在此先送分以表示我的诚意。我的目的是要在OE上加个菜单或工具条,而它的功能是操作OE的文件夹 存取 删除EMail信息等,希望各位能给我以更多的帮助,本人不胜感激,并会送分表谢!
      

  4.   

    我已经送了分了,但当看不到送分的情况,不知是我的操作错误还是网站的Bug啊。