Birinin kartvizitini Outlook'ta görüntülerken, ofisi konumlarını veren bir Office alanı vardır. Bunu VBA kullanarak nasıl bulabilirim? İşte benim en işlevsel kod: Onların gerçek adı (EG, John Smith) aradıklarındaVBA'da Exchange Kullanıcısının Office Konumunu Bul
Private Function getLocation(username As String) As String
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olGAL As Outlook.AddressEntries
Dim olAddressEntry As Outlook.AddressEntry
Dim olUser As Outlook.ExchangeUser
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olGAL = olNS.AddressLists("Global Address List").AddressEntries
Set olAddressEntry = olGAL.Item(username)
Set olUser = olAddressEntry.GetExchangeUser
Debug.Print olGAL.Count 'count is 646718
Debug.Print olUser.OfficeLocation
Debug.Print olUser.Address
Debug.Print olUser.Name
getLocation = olUser.OfficeLocation
Set olApp = Nothing
Set olNS = Nothing
Set olGAL = Nothing
Set olAddressEntry = Nothing
Set olUser = Nothing
End Function
Bu çalışır, ancak sadece ilk John Smith döndürür. Arama yapmak için e-posta adresini veya takma adını nasıl kullanabilirim?
Not: Intellisense'den yararlanmak için Microsoft Outlook 16.0 Object Library
'a bir başvuru ekledim, ancak çalıştıktan sonra geç bağlanmaya geçmeyi planlıyorum.