Results 1 to 1 of 1
2002-10-12, 17:55 #1
- Join Date
- Mar 2002
- Copenhagen, Denmark
- Thanked 0 Times in 0 Posts
Accessing AddressLists when Outlook is Offline (XP(VBA))
I have done some Word2002 code that retrieves the name and address info on the currently logged-in user as well as a list of all users from the Global Address List in Outlook/Exchange (XP/2000). This all works fine. Now I want to add the same functionality even if the user is working offline. If I simulate being offline (just unplugging my network cable), I can start Outllok and I can see everything as usual - of course I have set up my Outlook client to be able to work offline. Outlook obviously knows my name and I can see the Global Addres List - presented to me as "Offlineaddressbook" (my translation from Danish in my localized version), but how do I get to this info from my VBA code??
I have tried something like this:
Set objCurrentUser = CreateObject("Redemption.SafeCurrentUser")
strSignature1 = objCurrentUser.Name
Set objCurrentUser = Nothing
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objAddressLists As Outlook.AddressLists
Dim objAddressList As Outlook.AddressList
Dim objAddressEntries As Outlook.AddressEntries
Dim objAddressEntry As Outlook.AddressEntry
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace(Type:="MAPI")
Set objAddressLists = objNameSpace.AddressLists
For Each objAddressList In objAddressLists
Set objAddressList = objAddressLists("Offlineadressekartotek")
Set objAddressEntries = objAddressList.AddressEntries
For Each objAddressEntry In objAddressEntries
The first part is using Outlook Redemption (to avoid the Outlook Automation Security) to obtain the users name - and it works one time (only), next time around it gives me nothing in "strSignature1". I also need to get specific address-info on the user, but I haven't come around to this yet.
The second part is not using Redemption (but probably I will have to do it), and it is my feeble attempt to access the offline version of the Global Address List. The "Debug.Print objAddressList.Name" shows me that I have 2 addresslists, one of them is named "Offlineadressekartotek" in my Danish version of Outlook, but I cannot connect to it (using "Set objAddressList = objAddressLists("Offlineadressekartotek")" does not give me a reference to the desired list.
I am not sure if I should post my question here or in VB/VBA forum, but I think my problem is understanding the Outlook Object Model and how Outlook works offline, so I try here first.
Does anybody have any good ideas??