Closed
Bug 250757
Opened 20 years ago
Closed 19 years ago
MAPIFindNext always returns MAPI_E_FAILURE
Categories
(MailNews Core :: Simple MAPI, defect)
Tracking
(Not tracked)
RESOLVED
EXPIRED
People
(Reporter: paul2, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8 Build Identifier: 0.7.2 After I make Thunderbird the default mail client I try and execute a MAPIFindNext() call against it. The call always returns MAPI_E_FAILURE no matter what variation of arguments I try. The same calls work with Outlook Express and Outlook. Reproducible: Always Steps to Reproduce: If attached the source to a class as additional information. 1. Call Initialize() 2. Call Logon() 3. Call NewMessageCount() Actual Results: The call to MAPIFindNExt() in NewMessageCount() always returns MAPI_E_FAILURE Expected Results: SUCCESS_SUCCESS and a valid message ID. // MAPIMailCheck.cpp: implementation of the MAPIMailCheck class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <time.h> #include "MAPIMailCheck.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// MAPIMailCheck::MAPIMailCheck() : name(""), password(""), m_hMapi(0), //Instance handle of the MAPI dll m_hSession(0), //Mapi Session handle m_nLastError(0), //Last Mapi error value m_lpfnMAPILogon(0), //MAPILogon function pointer m_lpfnMAPILogoff(0), //MAPILogoff function pointer m_lpfnMAPISendMail(0), //MAPISendMail function pointer m_lpfnMAPIResolveName(0), //MAPIResolveName function pointer m_lpfnMAPIFreeBuffer(0), //MAPIFreeBuffer function pointer m_lpfnMAPIReadMail(0), //MAPIReadMail function pointer m_lpfnMAPIFindNext(0), //MAPIFindNext function pointer validDays(0) { } MAPIMailCheck::~MAPIMailCheck() { Destroy(); if (m_hMapi) { //Unload the MAPI dll and reset the function pointers to NULL FreeLibrary(m_hMapi); m_hMapi = NULL; m_lpfnMAPILogon = NULL; m_lpfnMAPILogoff = NULL; m_lpfnMAPISendMail = NULL; m_lpfnMAPIResolveName = NULL; m_lpfnMAPIFreeBuffer = NULL; m_lpfnMAPIFindNext = NULL; m_lpfnMAPIReadMail = NULL; } } LRESULT MAPIMailCheck::Logon() { LRESULT res = E_FAIL; if (m_hMapi) { Logoff(); //Setup the flags & UIParam parameters used in the MapiLogon call FLAGS flags = 0; ULONG nUIParam = 0; //First try to acquire a new MAPI session using the supplied settings using the MAPILogon functio ULONG nError = m_lpfnMAPILogon(nUIParam, name, password, flags | MAPI_NEW_SESSION, 0, &m_hSession); if (nError != SUCCESS_SUCCESS && nError != MAPI_E_USER_ABORT) { //Failed to create a create mapi session, try to acquire a shared mapi session AtlTrace("Failed to logon to MAPI using a new session, trying to acquire a shared one\n"); nError = m_lpfnMAPILogon(nUIParam, NULL, NULL, 0, 0, &m_hSession); if (nError == SUCCESS_SUCCESS) { m_nLastError = SUCCESS_SUCCESS; res = S_OK; } else { AtlTrace("Failed to logon to MAPI using a shared session, Error:%d\n", nError); m_nLastError = nError; } } else if (nError == SUCCESS_SUCCESS) { m_nLastError = SUCCESS_SUCCESS; res = S_OK; } } return res; } LRESULT MAPIMailCheck::Logoff() { LRESULT res = E_FAIL; if (m_hSession) { //Call the MAPILogoff function ULONG nError = m_lpfnMAPILogoff(m_hSession, 0, 0, 0); if (nError != SUCCESS_SUCCESS) { AtlTrace("Failed in call to MapiLogoff, Error:%d\n", nError); m_nLastError = nError; } else { m_nLastError = SUCCESS_SUCCESS; res = S_OK; } m_hSession = 0; } return S_OK; } LRESULT MAPIMailCheck::Initialize(_bstr_t username, _bstr_t password, long validDays) { LRESULT res = E_FAIL; this->name = username; this->password = password; this->validDays = validDays; //First make sure the "WIN.INI" entry for MAPI is present aswell //as the MAPI32 dll being present on the system BOOL bMapiInstalled = (GetProfileInt("MAIL", "MAPI", 0) != 0) && (SearchPath(NULL, "MAPI32.DLL", NULL, 0, NULL, NULL) != 0); if (bMapiInstalled) { //Load up the MAPI dll and get the function pointers we are interested in m_hMapi = LoadLibrary("MAPI32.DLL"); if (m_hMapi) { m_lpfnMAPILogon = (LPMAPILOGON) GetProcAddress(m_hMapi, "MAPILogon"); m_lpfnMAPILogoff = (LPMAPILOGOFF) GetProcAddress(m_hMapi, "MAPILogoff"); m_lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(m_hMapi, "MAPISendMail"); m_lpfnMAPIResolveName = (LPMAPIRESOLVENAME) GetProcAddress(m_hMapi, "MAPIResolveName"); m_lpfnMAPIFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress(m_hMapi, "MAPIFreeBuffer"); m_lpfnMAPIFindNext = (LPMAPIFINDNEXT) GetProcAddress(m_hMapi, "MAPIFindNext"); m_lpfnMAPIReadMail = (LPMAPIREADMAIL) GetProcAddress(m_hMapi, "MAPIReadMail"); //If any of the functions are not installed then fail the load if (m_lpfnMAPILogon == NULL || m_lpfnMAPILogoff == NULL || m_lpfnMAPISendMail == NULL || m_lpfnMAPIResolveName == NULL || m_lpfnMAPIFreeBuffer == NULL || m_lpfnMAPIReadMail == NULL || m_lpfnMAPIFindNext == NULL) { AtlTrace("Failed to get one of the functions pointer in MAPI32.DLL\n"); Destroy(); } else { Logon(); res = S_OK; } } } else AtlTrace("Mapi is not installed on this computer\n"); return res; } LRESULT MAPIMailCheck::Destroy() { if (m_hMapi) { Logoff(); } return S_OK; } LRESULT MAPIMailCheck::Configure(IObserver * observer, LONG hWnd) { return S_OK; } BOOL MAPIMailCheck::IsInDate(char *id, char *validDate) { BOOL ret = false; if (validDays <= 0) return true; FLAGS flags = MAPI_ENVELOPE_ONLY | MAPI_PEEK; lpMapiMessage pMsg; ULONG nError = m_lpfnMAPIReadMail(m_hSession, NULL, id, flags, 0, &pMsg ); if (nError == SUCCESS_SUCCESS) { AtlTrace("Message received on %s ", pMsg->lpszDateReceived); if (strcmp(pMsg->lpszDateReceived, validDate) > 0) { AtlTrace("is in date\n"); ret = true; } else { AtlTrace("is out of date\n"); } nError = m_lpfnMAPIFreeBuffer(pMsg); } else AtlTrace("Could net get message envelope"); return ret; } LRESULT MAPIMailCheck::NewMessageCount(long *pRet) { int ret = 0; char timeBuf[64]; *timeBuf = 0; if (validDays > 0) { time_t t; ::time(&t); t -= validDays*3600*24; struct tm *lt; lt = localtime(&t); // YYYY/MM/DD HH:MM strftime(timeBuf, 63, "%Y/%m/%d %H:%M", lt); } LPTSTR id; id = new char[512]; *id = NULL; FLAGS flags = MAPI_UNREAD_ONLY; ULONG nError = m_lpfnMAPIFindNext(m_hSession, 0, NULL, id, flags, 0, id ); while ( nError == SUCCESS_SUCCESS ) { if (IsInDate(id, timeBuf)) ret++; nError = m_lpfnMAPIFindNext(m_hSession, 0, NULL, id, flags, 0, id ); } delete [] id; *pRet = ret; return S_OK; }
Updated•20 years ago
|
Assignee: mscott → nobody
Component: General → Simple MAPI
Product: Thunderbird → MailNews
Version: unspecified → Trunk
I found the same. No matter what parameters I use MAPIFindNext fails! ret = 2 = MAPI_E_FAILURE Other functions like MAPISendMail work correct. Robert ################# Python 2.3 ################### def SyncInbox(self,cbMsg=None): from ctypes import c_ulong,c_char_p import win32com.mapi.mapi as wmapi mapi=ctypes.WinDLL(r"c:/Programme/mozilla.org/mozilla/mozMapi32.dll") print "MapiDllVersion", mapi.GetMapiDllVersion() #---- shandle=" " profile="me" pwd="" mapi.MAPILogon.argtypes = [c_ulong, c_char_p, c_char_p, c_ulong, c_ulong, c_char_p] ret = mapi.MAPILogon( 0, #ULONG ulUIParam, profile, #LPTSTR lpszProfileName, pwd, #LPTSTR lpszPassword, 0, #FLAGS flFlags, 0, #ULONG ulReserved, shandle ) h = struct.unpack("i",shandle)[0] print "MAPILogon",ret,"H:[%s]"%h #----- msgid=" "*513 MAPI_LONG_MSGID = 0x00004000 mapi.MAPIFindNext.argtypes = [c_ulong, c_ulong, c_char_p, c_char_p, c_ulong, c_ulong, c_char_p] ret = mapi.MAPIFindNext( h, #LHANDLE lhSession, 0, #ULONG ulUIParam, None, #0, #LPTSTR lpszMessageType, None, #LPTSTR lpszSeedMessageID, MAPI_LONG_MSGID, #FLAGS flFlags, 0, #ULONG ulReserved, msgid, #LPTSTR lpszMessageID ) print "MAPIFindNext",ret,len(msgid), "[%s]"%msgid[:10] return ret,msgid ######## >>> MapiDllVersion 94 MAPILogon 0 H:[46] MAPIFindNext 2 513 [ ] >>>
.. and I checked the above code with other MAPI DLLs from Netscape 4.72, Outlook Express, Outlook, Eudora. They all work. Strange that Netscape 4.72 also works correct, but not Mozilla 1.7 & 1.6 !?
Updated•20 years ago
|
Product: MailNews → Core
Comment 3•19 years ago
|
||
This is an automated message, with ID "auto-resolve01". This bug has had no comments for a long time. Statistically, we have found that bug reports that have not been confirmed by a second user after three months are highly unlikely to be the source of a fix to the code. While your input is very important to us, our resources are limited and so we are asking for your help in focussing our efforts. If you can still reproduce this problem in the latest version of the product (see below for how to obtain a copy) or, for feature requests, if it's not present in the latest version and you still believe we should implement it, please visit the URL of this bug (given at the top of this mail) and add a comment to that effect, giving more reproduction information if you have it. If it is not a problem any longer, you need take no action. If this bug is not changed in any way in the next two weeks, it will be automatically resolved. Thank you for your help in this matter. The latest beta releases can be obtained from: Firefox: http://www.mozilla.org/projects/firefox/ Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html Seamonkey: http://www.mozilla.org/projects/seamonkey/
Comment 4•19 years ago
|
||
This bug has been automatically resolved after a period of inactivity (see above comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → EXPIRED
Assignee | ||
Updated•16 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•