A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Unable to enumerate Mailboxes in NON Cached Mode (if more than 2)



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old July 17th 09, 05:41 PM posted to microsoft.public.outlook.program_vba
stefanom74
external usenet poster
 
Posts: 5
Default Unable to enumerate Mailboxes in NON Cached Mode

Hi Ken,

Thanks a lot for you interest.

I tried to get All Pubilc Folders folder and i got the same Error:
"Microsoft Exchange is not available. Either there are network problems or
the Exchange computer is down for maintenance".

At this point I think this is a problem of my Exchange 2007 installation ...
I will try reinstalling the Dev environment and will let you know if got
fixed ...

.... but anyway ... since this "problem" may occur when Exchange is not
available (i know it is strange in NON Cached Mode) how can i solve the
foreach problem!?
Since everything is started developing a VSTO 3SP1 c# Outlook Addin while I
was trying to enumerates Stores ... and Application.Session.Stores is not an
array of Outlook.Store but it is IEnumerable and can be accessed just with
foreach (or equivalent) ... how can I enumerate all Stores with a for (int
i=0;....) in order to put error handling on each item ?!?

Thanks!
Regards,
Stefano



"Ken Slovak - [MVP - Outlook]" wrote:

I tested both code methods (with the For...Each and For loops) here on
Outlook 2007 in both online and cached modes and ran the code with no
errors. I got the display name for public folders with no errors.

Let's try a couple of tests.

First, when you iterate the stores get each one as a Store object. Make sure
you can do that with the public folders store and as a Store object try to
access DisplayName. Do that instead of using those compound dot operators
(oNS.Stores(i).DisplayName). They make it hard to see exactly where the
error is occurring.

Second, try getting the All Public Folders folder using
oNS.GetDefaultFolder(olPublicFoldersAllPublicFolde rs) and see if you get a
valid Folder object and if you can access its properties such as Name.

I'm amazed that this is happening in online mode, if anything I'd expect
some problem with cached mode rather than online mode.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"stefanom74" wrote in message
...
Hi Ken,

Thanks for the reply.

I found the problem !

I tried your code but it returns the same Automation Error (on "Next"
statement), then i tried to change the code from "for each" to a simple
(for
index=1 to oNS.Count) ... and here it is !!! The "real" error appeared
"Unable to connect Exchange...." while accessing to the DisplayName
store's
property (not on "Next i" statement). The error was on the "Public
Folders"
that is enumerated as store too!
An error handling inside the "For" will probably "solve" the problem.
(but why the "For Each" statement doesn't have the same behavior?)


This is the update code:

Sub TestBug()
Dim store As store
Dim oNS As Outlook.NameSpace
Set oNS = Application.GetNamespace("MAPI")
MsgBox (oNS.Stores.Count) '- this returns 3
For i = 1 To oNS.Stores.Count
MsgBox (oNS.Stores(i).DisplayName) ' - this returns Error on i =
2
Next i
End Sub

Regards,
Stefano



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Appointments and Cached Mode Delores Outlook - Calandaring 1 September 10th 08 08:56 PM
Configure cached mode for additional mailboxes configured on a pro Doria Outlook - Installation 0 May 8th 08 01:51 PM
Cached Mode for "Other Mailboxes" + Exchange Hasan Sheriff[_2_] Outlook - General Queries 1 January 17th 08 02:37 AM
Outlook 2007 cached mode with additional mailboxes [email protected] Outlook - General Queries 1 August 13th 07 03:04 PM
Unable to use out look with Cached Exchange Mode enabled [email protected] Outlook - General Queries 6 October 26th 06 03:00 AM


All times are GMT +1. The time now is 11:30 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.