Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / February 2005

Tip: Looking for answers? Try searching our database.

Retrieving Contact data without using a MAPI call

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SDecou - 23 Feb 2005 17:05 GMT
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
Ken Slovak - [MVP - Outlook] - 23 Feb 2005 22:26 GMT
Extended MAPI or CDO 1.21 would be faster, you could speed it up somewhat by
using a For Each loop instead of a For Next loop. If you're using cached
mode you really are using a local copy of the data from the OST file.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Using the code below I am able to display my Contact folders and the
> entries
[quoted text clipped - 63 lines]
>
> End Function
SDecou - 25 Feb 2005 14:21 GMT
Could you recommend a site where I could find code examples of what I am
doing below using Extended MAPI or CDO 1.21?  Thanks.

> Extended MAPI or CDO 1.21 would be faster, you could speed it up somewhat by
> using a For Each loop instead of a For Next loop. If you're using cached
[quoted text clipped - 67 lines]
> >
> > End Function
Ken Slovak - [MVP - Outlook] - 25 Feb 2005 20:46 GMT
For MAPI you would have to search in the KB or MSDN library or maybe google
for MAPI samples. For CDO 1.21 you can look at www.cdolive.com/cdo5.htm for
code samples.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Could you recommend a site where I could find code examples of what I am
> doing below using Extended MAPI or CDO 1.21?  Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.