sorry, justrealised a silly mistake!!!

-----Original Message-----
From: Jon Hill [mailto:[EMAIL PROTECTED]]
Sent: 02 July 2002 17:01
To: Exchange Discussions
Subject: RE: VB - Retrieving contacts from Exchange Server


Your code used the Outlook Object Model, so the following code should work:

Set olNS = ol.GetNamespace("MAPI")
Set olGAL = olNS.AddressLists("Global Address List")

For Each olThisBox In olGAL.AddressEntries
    If olThisBox.DisplayType = olUser Then
        Set mailbox = olNS.CreateRecipient(outThisBox.Name)
...insert code here...
    End If
Next



It would probably run faster if you used the CDO model.  The following might
get you started:



Sub FindMessageCDO()
'find all messages whose subject contains a particular line of text
Dim strProfileInfo As String
Dim cdoSession As New MAPI.Session
Dim cdoGAL As MAPI.AddressList
Dim cdoMailboxes As MAPI.AddressEntries
Dim cdoThisBox As MAPI.AddressEntry
Dim cdoInbox As MAPI.Folder
Dim cdoInboxMsgs As MAPI.Messages
Dim cdoInboxFilter As MAPI.MessageFilter
Dim cdoThisMsg As MAPI.Message
Dim cdoOtherSession As MAPI.Session
Dim iBadMsgCount As Integer
Dim dtmStart As Date
    

Const strSUBJ = "Homepage"

strExchServer="MyMailServer"
strMailbox = "MyMailbox"
strProfileInfo = strExchServer + vbLf + strMailbox

Set cdoGAL = cdoSession.AddressLists("Global Address List")

For Each cdoThisBox In cdoGAL.AddressEntries
    
    With cdoThisBox
        If .DisplayType = olUser Then
            iBadMsgCount = 0
            
            Set cdoOtherSession = Application.CreateObject("Mapi.Session")
            
            strProfileInfo = strExchServer + vbLf + .Address
            cdoOtherSession.Logon "", "", False, True, 0, True,
strProfileInfo

            On Error Resume Next
            Set cdoInbox = cdoOtherSession.Inbox
            If Err = 0 Then
                On Error GoTo 0
                Set cdoInboxMsgs = cdoOtherSession.Inbox.Messages
...insert code here...
                Set cdoInboxMsgs = Nothing
            End If
        End If
    End With
Next


End Sub

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

Reply via email to