none
Error when trying to open more than 100 calendars RRS feed

  • Question

  • Hi

    I am writing an application that accesses some 200 users' calendars in a foreach loop and get the calendar appointments for some dates.

    foreach (User user in _users)

    {

                RDOFolder objFolder = null;

                try

                {

                    RDOAddressEntry add = _session.AddressBook.ResolveName(user, false, 0);

                    objFolder = _session.GetSharedDefaultFolder(add, rdoDefaultFolders.olFolderCalendar);

                }

               catch (Exception ex)

                {

                    Log.WriteToFile("Error in getting folder: " + user + "    " + ex.Message);

                }

                if (objFolder != null)

                {

                    //Get calendar items.. and release them.

    Marshal.ReleaseComObjeect(objFolder);

              GC.Collect();

               }

    }

    It works fine for around 100 users but after that for all the users it gave the error like 

    Error in IMAPISession::OpenMsgStore: MAPI_E_FAILONEPROVIDER

    ulVersion: 0

    Error: The information store could not be opened.

    Component: MAPI 1.0

    ulLowLevelError: 0

    ulContext: 649

    Then when I was working with Outlook 2010, I fixed it by unchecking the check box "Download shared folders" in (Accounts settingsà Select the account, and click Change à More settings à Advanced tab à Uncheck “Download shared folders”)

    But now I am doing this against Exchange Server MAPI client (http://www.microsoft.com/en-us/download/details.aspx?id=1004) because I am running it in some server. Now I am getting the same problem and I dont know how to do the same in MAPI client (similar to Uncheck “Download shared folders”) .

    Any help is appretiated.

    Thanks in advance

    Geetha



    Thursday, March 14, 2013 2:29 PM

All replies

  • You are running out of RPC channels. Each Outlook object uses an RPC channel, and the Exchange default is to allow you about 255 RPC channels. Then you get out of memory errors.
     
    foreach() loops are bad as you can't initialize the object and you can't release it. Do something like this to make sure you are creating the minimum number of objects and releasing them:
     
    User user = null;
    RDOFolder objFolder = null;
    RDOAddressEntry add = null;
     
    for (int i = 1; i < _users.Count; i++)
    {
        user = _users[i];
       
        // set objFolder and add
     
        // do whatever
     
        // now call Marshal.ReleaseComObject() on user, objFolder, add, then set them == null.
    } // end loop

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "gr_gr" <=?utf-8?B?Z3JfZ3I=?=> wrote in message news:78e0abf2-73dd-44b3-a176-bf78a8e0af8a...

    Hi

    I am writing an application that accesses some 200 users' calendars in a foreach loop and get the calendar appointments for some dates.

    foreach (User user in _users)

    {

                RDOFolder objFolder = null;

                try

                {

                    RDOAddressEntry add = _session.AddressBook.ResolveName(user, false, 0);

                    objFolder = _session.GetSharedDefaultFolder(add, rdoDefaultFolders.olFolderCalendar);

                }

               catch (Exception ex)

                {

                    Log.WriteToFile("Error in getting folder: " + user + "    " + ex.Message);

                }

                if (objFolder != null)

                {

                    //Get calendar items.. and release them.

    Marshal.ReleaseComObjeect(objFolder);

              GC.Collect();

               }

    }

    It works fine for around 100 users but after that for all the users it gave the error like 

    Error in IMAPISession::OpenMsgStore: MAPI_E_FAILONEPROVIDER

    ulVersion: 0

    Error: The information store could not be opened.

    Component: MAPI 1.0

    ulLowLevelError: 0

    ulContext: 649

    Then when I was working with Outlook 2010, I fixed it by unchecking the check box "Download shared folders" in (Accounts settingsà Select the account, and click Change à More settings à Advanced tab à Uncheck “Download shared folders”)

    But now I am doing this against Exchange Server MAPI client (http://www.microsoft.com/en-us/download/details.aspx?id=1004) because I am running it in some server. Now I am getting the same problem and I dont know how to do the same in MAPI client (similar to Uncheck “Download shared folders”) .

    Any help is appretiated.

    Thanks in advance

    Geetha




    Ken Slovak MVP - Outlook
    Thursday, March 14, 2013 2:48 PM
    Moderator
  • Hi 

    "User" is my own class that I have created. It has got to do nothing with the MAPI. And I cannot dispose it as I use it in many places.

    Is there any other way of closing and releasing the calendar folder and not downloading it. Now I guess the shared folders are downloaded and the RPC connections are made all the time.

    -Geetha

    Friday, March 15, 2013 8:04 AM
  • I would still move the declaration of the RDOFolder and RDOAddressEntry objects outside of the foreach() loop. I'd also call ReleaseComObject() on both objects in each loop pass and set each to null after the release call in each loop pass. That will make a big difference I think.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "gr_gr" <=?utf-8?B?Z3JfZ3I=?=> wrote in message news:6672b3c0-8662-42e6-a26d-bea2fbc418b6...

    Hi 

    "User" is my own class that I have created. It has got to do nothing with the MAPI. And I cannot dispose it as I use it in many places.

    Is there any other way of closing and releasing the calendar folder and not downloading it. Now I guess the shared folders are downloaded and the RPC connections are made all the time.

    -Geetha


    Ken Slovak MVP - Outlook
    Friday, March 15, 2013 6:02 PM
    Moderator
  • Hi

    I tried moving everything globally, but does'nt work.

    I changed the program so that now it creates a new session for every user. For every user it creates a new RDOSession and logons everytime. Then I don’t get the problem. 

    But now, with creating a new session for every user and logging in everytime, after logging in  for some users, at some point it asks for the credentials while logging in. I would say it asks once after around 55 users and then proceeds till the end.

    This is the code I use for logon to exchange.

    RDOSession  session = new RDOSession();

    session.LogonExchangeMailbox(currentUser, exchangeAddress); 

    How can I prevent this?

    Thanks

    Geetha

    Monday, March 18, 2013 10:16 AM
  • Infact, exactly at 51st user.
    Monday, March 18, 2013 10:32 AM