13 replies
by fofa
by mnm82
Thanks for the Exchange ODBC suggestion but this adds a complexity I should not pursue at moment given project time-scale.
I have downloaded some examples that use Collaborative Data Objects CDO but cannot bind to some objects/methods to the underlining cdo.dll. I get Runtime error '429' ActiveX Component can't create object. Mind you this cdo.dll (ver 1.2) was not listed in the VB references and I had to browse to find it. Also, regsvr32 of cdo.dll failed with error 'LoadLibrary.....failed. - The specified module could not be found'. Guy and Gals I still need you r assistance. Please YELP!
by peyison
There are two sets of objects that contain address/contact information. The first is the Address Book, but you can only get Name and Email address (from what I can tell). Here's how that would work:
(you need to have a reference to the Outlook 9.0 Library)
Dim oNameSpace As Outlook.NameSpace
Dim oAddList As Outlook.AddressList
Dim oEntry As Outlook.AddressEntry
Set oNameSpace = Application.GetNamespace("MAPI")
For Each oAddList In oNameSpace.AddressLists
For Each oEntry In oAddList.AddressEntries
MsgBox oAddList.Name & " " & oEntry.Name & " " & oEntry.Address
'This pops up a details window
oEntry.Details
Next
Next
The other way is to use Contacts. From what I can tell this is the same info that appears in the Address List info, but I'm not sure how it works if you're running on an Exchange Server. You might not have info from your Global Address Book in your contact list. Here's how this works:
Dim oNameSpace As Outlook.NameSpace
Dim oContact As Outlook.ContactItem
Dim oFolder As Outlook.MAPIFolder
Set oNameSpace = Application.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderContacts)
For Each oContact In oFolder.Items
With oContact
MsgBox .FirstName & " " & .LastName & " " & .BusinessAddress & " " & .BusinessTelephoneNumber
End With
Next
Once you get this running, you should be able to play around in Help to get all the properties you need.
Hope this helps.
by shanghai sam
Thanks dor the response and suggestion. As a stop gap I have gone for the suggestion to copy Global Address List to Outlook Contacts. This progressed fine and can get all address entries (without Telephone details, Email etc..) if don't reference oContact.FirstName otherwise 'am getting a runtime error '13' type mismatch.
The working Code snippet is hereafter pasted.
Dim oNameSpace As Outlook.NameSpace
'Dim oContact As Outlook.ContactItem
Dim oContact As Variant
Dim oFolder As Outlook.MAPIFolder
Set oNameSpace = Application.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderContacts)
oFolder.Display
For Each oContact In oFolder.Items
'With oContact
'MsgBox .FirstName & " " & .LastName & " " & .BusinessAddress & " " & .BusinessTelephoneNumber
Debug.Print oContact
'End With
Next
By the way VB protests if you call a msgbox within an With ...End With construct.
I still need some more more delta help. We shall get there!!!
by peyison
The code worked fine for me, including the call to msgbox. There is no restriction in VB for calling msgbox within a With - End With clause.
by mnm82
by limbo
/Me backs up Peyison
And I once programmed POP-11 dontchaknow!!
by mnm82
by limbo
Err... USER DELETED!!!
You've asked over 280 questions and have a 100% unrated score!!!
100% !!!!?
Isn't that a slightly cheeky! And a liberty (to say the least) to take so much from such a valuable resource without giving anything back?
by mnm82
by limbo
Alas, I suppose I was getting a wee bit personal.
I will just ignore what I think is a transgression, and humbly request you do the same on my behalf.
:|
by mnm82
by mnm82
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending