G
Guest
Using the code below I am able to display my Contact folders and the entries
within the folders. The issue we are having is using this code to access
mailboxes across a WAN where we have one centralized server. We are using
Outlook 2003 client with cashing enabled. This allows us to access the
contact data quickly from the full client. The major delay occurs when
accessing this data from the code below. Is there another way to access this
information without using a MAPI call or downloading all folder data at once?
Any help would be appreciated. Thank you.
Sub GetFolderCount()
Dim MyFolder As Outlook.MAPIFolder
Dim j As Long
Dim MailboxName As String
Dim MailboxLoc As Integer
Set myOutlook = CreateObject("Outlook.Application")
Set myNS = myOutlook.GetNamespace("MAPI")
For j = 1 To myNS.Folders.Count
Set MyFolder = myNS.Folders.Item(j)
If InStr(MyFolder.Name, "Mailbox - ") <> 0 Then
MailboxName = MyFolder.Name
Call RecurseFolder(MyFolder, MailboxName)
End If
Next j
frmOutlookFolders.lstOutlookFolders.ListIndex = 0
frmOutlookFolders.lstOutlookFolders.Selected(0) = True
frmOutlookFolders.Show
End Sub
Function RecurseFolder(ByVal Thisfolder As Outlook.MAPIFolder, ByVal mbname
As String) As Long
Dim myInnerFolder As Outlook.MAPIFolder
Dim myTotal As Long, i As Long
myTotal = 1
On Error Resume Next
'Do not display deleted items folder in listing
If Thisfolder.Folders.Count > 0 And Thisfolder.Name <> "Deleted Items"
Then
For i = 1 To Thisfolder.Folders.Count
Set myInnerFolder = Thisfolder.Folders.Item(i)
If myInnerFolder.DefaultItemType = olContactItem Then
If Err.Number <> 0 Then
Err.Clear
Else
' If myInnerFolder.Name = "Contacts" Then
frmOutlookFolders.lstOutlookFolders.AddItem
myInnerFolder.Name & " - " & mbname
' Else
' frmOutlookFolders.lstOutlookFolders.AddItem
myInnerFolder.Name
' End If
frmOutlookFolders.lstInvisOutlookFolders.AddItem
myInnerFolder.EntryID
End If
End If
myTotal = myTotal + RecurseFolder(myInnerFolder, mbname)
Next i
End If
RecurseFolder = myTotal
End Function
within the folders. The issue we are having is using this code to access
mailboxes across a WAN where we have one centralized server. We are using
Outlook 2003 client with cashing enabled. This allows us to access the
contact data quickly from the full client. The major delay occurs when
accessing this data from the code below. Is there another way to access this
information without using a MAPI call or downloading all folder data at once?
Any help would be appreciated. Thank you.
Sub GetFolderCount()
Dim MyFolder As Outlook.MAPIFolder
Dim j As Long
Dim MailboxName As String
Dim MailboxLoc As Integer
Set myOutlook = CreateObject("Outlook.Application")
Set myNS = myOutlook.GetNamespace("MAPI")
For j = 1 To myNS.Folders.Count
Set MyFolder = myNS.Folders.Item(j)
If InStr(MyFolder.Name, "Mailbox - ") <> 0 Then
MailboxName = MyFolder.Name
Call RecurseFolder(MyFolder, MailboxName)
End If
Next j
frmOutlookFolders.lstOutlookFolders.ListIndex = 0
frmOutlookFolders.lstOutlookFolders.Selected(0) = True
frmOutlookFolders.Show
End Sub
Function RecurseFolder(ByVal Thisfolder As Outlook.MAPIFolder, ByVal mbname
As String) As Long
Dim myInnerFolder As Outlook.MAPIFolder
Dim myTotal As Long, i As Long
myTotal = 1
On Error Resume Next
'Do not display deleted items folder in listing
If Thisfolder.Folders.Count > 0 And Thisfolder.Name <> "Deleted Items"
Then
For i = 1 To Thisfolder.Folders.Count
Set myInnerFolder = Thisfolder.Folders.Item(i)
If myInnerFolder.DefaultItemType = olContactItem Then
If Err.Number <> 0 Then
Err.Clear
Else
' If myInnerFolder.Name = "Contacts" Then
frmOutlookFolders.lstOutlookFolders.AddItem
myInnerFolder.Name & " - " & mbname
' Else
' frmOutlookFolders.lstOutlookFolders.AddItem
myInnerFolder.Name
' End If
frmOutlookFolders.lstInvisOutlookFolders.AddItem
myInnerFolder.EntryID
End If
End If
myTotal = myTotal + RecurseFolder(myInnerFolder, mbname)
Next i
End If
RecurseFolder = myTotal
End Function