MAPIFindNext return NO_MESSAGE but there are emails in Windows Mai

  • Thread starter U2FtdWVsIE51bmVzIGRlIEFycnVkYQ
  • Start date Views 836
Status
Not open for further replies.
U

U2FtdWVsIE51bmVzIGRlIEFycnVkYQ

#1
Hi everybody,

I builted an aplication that read emails from MAPI. The MAPILogon returns
SUCCESS_SUCCESS, but when a try to send a MAPIFindNext before to use
MAPIReadMail the return code is MAPI_E_NO_MESSAGES. There are emails unreaded
in windows mail and i thing that the return code must be SUCCESS_SUCCESS for
MAPIFindNext.

I created an email account as "softools" and conected it to
samuel.softools@ig.com.br

The MAPI in WIN.INI is 1 and set to MAPI32.DLL. I Loaded the MAPI31.DLL
correctly with loadlibrary().

I have installed the windows vista and the office 2003. There are some
configuration needed for this softwares to use MAPI ?

I thing is everything is fine but nothing is happening

ULONG err; int flag = 0; char result[64];
if (!hMAPILib)
return CANT_LOAD;
else {
err = lpfnMAPILogon(0L,"","",MAPI_LOGON_UI ,0L, &lhSession);

switch(err) {

case MAPI_E_FAILURE:
mailbox.p_sErrorMsg = "MAPI LOGON - One or more unspecified errors
occurred during logon. No session handle was returned.";
flag=FAILMAIL;
break;

case MAPI_E_INSUFFICIENT_MEMORY:
mailbox.p_sErrorMsg = "MAPI LOGON - There was insufficient memory to
proceed. No session handle was returned.";
flag=FAILMAIL;
break;

case MAPI_E_LOGIN_FAILURE:
mailbox.p_sErrorMsg = "MAPI LOGON - There was no default logon, and the
user failed to log on successfully when the logon dialog box was displayed.
No session handle was returned.";
flag=FAILMAIL;
break;

case MAPI_E_TOO_MANY_SESSIONS:
mailbox.p_sErrorMsg = "MAPI LOGON - The user had too many sessions open
simultaneously. No session handle was returned.";
flag=FAILMAIL;
break;

case MAPI_E_USER_ABORT:
mailbox.p_sErrorMsg = "MAPI LOGON - The user canceled the logon dialog
box. No session handle was returned.";
flag=FAILMAIL;
break;

case SUCCESS_SUCCESS:
mailbox.p_sErrorMsg = "";
flag=FAILMAIL;
break;

default:
mailbox.p_sErrorMsg = "MAPI LOGON - Indefinido...";
flag=FAILMAIL;
break;
};
}
if (!mailbox.p_sErrorMsg.IsEmpty())
::MessageBox(NULL, result, mailbox.p_sErrorMsg, MB_OK);

if(err != SUCCESS_SUCCESS)
return CANT_LOGON;
else
return OK;

}

int STMail::ReadMail()
{
UINT index=0;
MapiMessage* message;
ULONG err=0;
char rgchMsgID[513]; // Message IDs should be >= 512 CHARs + a null.
bool bBool;

char result[64];

int flag=SUCCESS_SUCCESS;

if (NULL == hMAPILib)
{
::MessageBox(NULL, result, "Error 1/MAPI32.DLL", MB_OK);
return FAILMAIL;
}

ULONG uFindRet =SUCCESS_SUCCESS; // find the first unread message

uFindRet =lpfnMAPIFindNext(lhSession,0L,"","",MAPI_LONG_MSGID|MAPI_UNREAD_ONLY,0L,rgchMsgID);

switch(uFindRet)
{
case MAPI_E_NO_MESSAGES :
mailbox.p_sErrorMsg = "MAPIFindNext - MAPI_E_NO_MESSAGES";
flag = NOMAIL;
break;

case MAPI_E_FAILURE :
mailbox.p_sErrorMsg = "MAPIFindNext - MAPI_E_FAILURE";
flag = FAILMAIL;
break;

case MAPI_E_INSUFFICIENT_MEMORY :
mailbox.p_sErrorMsg = "MAPIFindNext - MAPI_E_INSUFFICIENT_MEMORY";
flag = FAILMAIL;
break;

case MAPI_E_INVALID_MESSAGE :
mailbox.p_sErrorMsg = "MAPIFindNext - MAPI_E_INVALID_MESSAGE";
flag = FAILMAIL;
break;

case MAPI_E_INVALID_SESSION :
mailbox.p_sErrorMsg = "MAPIFindNext - MAPI_E_INVALID_SESSION";
flag = FAILMAIL;
break;
}

if (flag==FAILMAIL) {
::MessageBox(NULL, result, _T(mailbox.p_sErrorMsg), MB_OK);
return flag;
}
else if (flag==NOMAIL)
return flag;

err = lpfnMAPIReadMail(lhSession,0L,rgchMsgID,MAPI_BODY_AS_FILE,0,&message);

if(err != SUCCESS_SUCCESS) // Make sure MAPIReadMail succeeded.
{
switch(err)
{
case MAPI_E_ATTACHMENT_WRITE_FAILURE :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_ATTACHMENT_WRITE_FAILURE";
flag=FAILMAIL;
break;
case MAPI_E_DISK_FULL :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_DISK_FULL";
flag=FAILMAIL;
break;
case MAPI_E_FAILURE :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_FAILURE";
flag=FAILMAIL;
break;
case MAPI_E_INSUFFICIENT_MEMORY :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_INSUFFICIENT_MEMORY";
flag=FAILMAIL;
break;
case MAPI_E_INVALID_MESSAGE :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_INVALID_MESSAGE";
flag=FAILMAIL;
break;
case MAPI_E_INVALID_SESSION :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_INVALID_SESSION";
flag=FAILMAIL;
break;
case MAPI_E_TOO_MANY_FILES :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_TOO_MANY_FILES";
flag=FAILMAIL;
break;
case MAPI_E_TOO_MANY_RECIPIENTS :
mailbox.p_sErrorMsg = "ReadMail - MAPI_E_TOO_MANY_RECIPIENTS";
flag=FAILMAIL;
break;
default :
mailbox.p_sErrorMsg = "ReadMail - Indefinido...";
flag=FAILMAIL;
break;
}

::MessageBox(NULL, result, _T(mailbox.p_sErrorMsg), MB_OK);
return flag;
}
else
{

Some can help me ?
SNArruda
 
#2
"Samuel Nunes de Arruda" <SNArruda@discussoes.microsoft.com> wrote in message
news:9D5CBC7F-AC9A-4E6B-B500-737AA259F4F7@microsoft.com...

> I builted an aplication that read emails from MAPI.


Ask coding questions in microsoft.public.outlook.program_vba

 
Status
Not open for further replies.

Similar threads

Top