我有以下代码(我在论坛上找到它):
Public Sub GetUsers() Dim myolApp As Outlook.Application Dim myNameSpace As Namespace Dim myAddrList As AddressList Dim myAddrEntries As addressEntry Dim AliasName As String Dim i As Integer, r As Integer Dim EndRow As Integer, n As Integer Dim myStr As String, c As Range Dim myPhone As String 'Dim propertyAccessor As Outlook.propertyAccessor 'This only works with 2007 and may help you out Set myolApp = CreateObject("Outlook.Application") Set myNameSpace = myolApp.GetNamespace("MAPI") Set myAddrList = myNameSpace.addressLists("Global Address List") Dim FullName As String, LastName As String, FirstName As String Dim StartRow As Integer EndRow = Cells(Rows.Count, 3).End(xlUp).Row StartRow = InputBox("At which row should this start?", "Start Row", 4) For Each c In Range("A" & StartRow & ":A" & CStr(EndRow)) AliasName = LCase(Trim(c)) c = AliasName Set myAddrEntries = myAddrList.addressEntries(AliasName) FullName = myAddrEntries.Name FirstName = Trim(Mid(FullName, InStr(FullName, "(") + 1, _ InStrRev(FullName, " ") - InStr(FullName, "("))) LastName = Right(FullName, Len(FullName) - InStrRev(FullName, " ")) LastName = Left(LastName, Len(LastName) - 1) c.Offset(0, 1) = FirstName c.Offset(0, 2) = LastName c.Offset(0, 3) = FirstName & " " & LastName Next c End Sub
当我提供单个名称(第一个或最后一个)时,它会在地址簿中查找它并返回它找到的人的名字和姓氏.
我想提供该人的企业ID,让它寻找,然后返回其他信息(位置,电话号码等).
我无法弄清楚如何做到这一点.首先,我不知道outlook如何只搜索Alias,据我所知,它只在局部变量中声明.此外,当我尝试提取其他信息时,例如:
HomeState = myAddrEntries.HomeState
我收到一个错误:对象不支持此属性或方法.我不知道该属性会被调用 - 我找不到任何在线文档,显示属性的命名方式(即使我搜索了MAPI docuemntation).
所以,我的问题是 - 如何使用此代码按ID搜索并返回其他属性,如位置,数字等.另外 - 我如何概括该过程 - 是否有一个列表,这些字段名称被称为,是否有一种生成列表的方法?
谢谢!