Quantcast
Channel: MFCMAPI
People Here Also Viewed:
Viewing all articles
Browse latest Browse all 1090

New Post: Error : Cannot open your default e-mail folders. the file ..outlook.pst is in use and cannot be accessed.

0
0
Hi,

I have written a multithreaded console application, which fetches all contacts. Sometimes(on some machines) when this MAPI application is running, and I open the outlook, I get the following message in the Outlook.
Cannot open your default e-mail folders. the file ..outlook.pst is in use and cannot be accessed.

Following is the code snippet
//Mapiinitialize with MAPI_MULTITHREAD_NOTIFICATIONS
MAPIInitialize();

// Login
MAPILogonEx(0,
    (LPTSTR)csProfileName.c_str(),
    (LPTSTR)csProfilePassword.c_str(),
    MAPI_EXTENDED | MAPI_NO_MAIL | MAPI_NEW_SESSION | MAPI_USE_DEFAULT,
    &m_lpMAPISession);

//Open the default message store        
m_lpMAPISession->OpenMsgStore(0,                                                            //Window handle for dialogs
            sRows->aRow[0].lpProps[ePR_ENTRYID].Value.bin.cb,               //size and...
            (LPENTRYID)sRows->aRow[0].lpProps[ePR_ENTRYID].Value.bin.lpb,   //value of entry to open
            NULL,                                                       //Use default interface (IMsgStore) to open store
            MDB_NO_MAIL|MDB_NO_DIALOG,                                          //Flags
            &m_lpMsgStore);                                         //Pointer to place the store in

//Open Inbox
m_lpMsgStore->GetReceiveFolder( NULL,      //Get default receive folder
            0,      //Flags
            &cbInbox,  //Size and ...
            &lpbInbox, //Value of the EntryID to be returned
            NULL);     //You don't care to see the class returned

m_lpMsgStore->OpenEntry(    cbInbox,                      //Size and...
            lpbInbox,                     //Value of the Inbox's EntryID
            NULL,                         //We want the default interface    (IMAPIFolder)
            0,                            //Flags
            &ulObjType,                   //Object returned type
            (LPUNKNOWN *) &m_lpInboxFolder); //Returned folder      

//Get Contacts
m_lpMsgStore->OpenEntry(    cb,
            lpContactEid,
            NULL,           //default interface
            0,
            &ulObjType,
            (LPUNKNOWN *) &lpFolder);

//read all contacts
lpFolder->GetContentsTable(0, &lpContentsTable);

Sleep(1000000);

UlRelease(m_lpMsgStore);
Release all other objects

MapiLogOff()

MapiUninitalize()
Note: I have also implemented the message loop(i.e using HRDispatchNotifications in the main tread which calls MapiInitialize.

Any help is appreciated.

Would it happen because I keep the MessageStore Open for long?? Or should I use some specific flags with OpenMsgStore.

Regards,
Rohan

Viewing all articles
Browse latest Browse all 1090

Latest Images

Trending Articles





Latest Images