Forum Discussion

ischerbakov's avatar
Occasional Contributor
7 years ago

Problem with MAPI (can't receive recent emails)


I use Microsoft Outlook 2010 to receive messages with attachments under TestComplete 12.42 x64 with Windows 10.

Very often I can find, that MAPI returns to me outdated or invalid number of items in he box.

For example, I know, that mail box containing new email and can see, that this email is already received by Outlook, but MAPI provides for me, that this email does not exists.



var OutlookApplication = Sys.OleObject("Outlook.Application");
var NamespaceMAPI = OutlookApplication.GetNamespace("MAPI");

if (NamespaceMAPI.Accounts.Item("") !== null)


    inbox = NamespaceMAPI.Folders(accountName).Folders("Inbox");
    items = inbox.Items;






If I move this code to cycle, and will debug number of items in the box, some times I can get following results (as example):   11 emails, 10 email, 10 email, ...........


If I terminate script in the TestComplete and run it again, then emails, which comes to box during previous test, will be appeared, but new emails will not as usual.


I tried to terminate OUTLOOK.EXE application manually from bat files, but these actions doesn't bring 100% effect.


Full version of my function you can find in the attachment.


Thanks for help.


No RepliesBe the first to reply