이것은 당신에게 당신을 줄 것입니다.
Private Function GetFullName(inAlias As String) As String
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olAdd As Outlook.AddressEntries
Dim olMem As Outlook.AddressEntry
Dim olLst As Outlook.AddressList
Dim olAlias As String
On Error Resume Next
Set olApp = New Outlook.Application
On Error GoTo 0
If olApp Is Nothing Then
GetFullName = "Source not available"
Exit Function
End If
Set olNS = olApp.GetNamespace("MAPI")
Set olLst = olNS.GetGlobalAddressList
Set olAdd = olLst.AddressEntries
For Each olMem In olAdd
On Error Resume Next
olAlias = olMem.GetExchangeUser.Alias
On Error GoTo 0
If olAlias = inAlias Then
GetFullName = olMem.GetExchangeUser.Name
Exit For
Else
GetFullName = "Invalid Alias"
End If
Next
Set olApp = Nothing: Set olNS = Nothing: Set olAdd = Nothing
End Function
GAL이 상당히 클 경우 다소 시간이 걸릴 수 있습니다.
배열을 먼저 덤프하고 거기에서 조작 할 수 있는지 확인합니다.
또는 다른 방법을 사용하여 별칭을 통해 이름을 가져 오는 다른 방법이있는 경우
하지만 지금 당장은 먼저 이것을 배우십시오.
이
TextBox2 = GetFullname(TextBox1)
참고 :
이
은 간단하게 할 수있는, 그래서 당신의 텍스트 상자에 그걸 얻기 위해, 함수 내가 의도적으로 모든 개체를 선언
, 당신이 알아야 할 객체의 어떤 종류 노력하고있어. 또한
Alias
없이
AddressEntry
이 있고 오류가 발생하여
On Error Resume Next을 사용했습니다. 그것은 내가 생각할 수있는 가장 쉬운 작업입니다.
요구 사항 : 당신은 Microsoft Outlook xx.x Object Library
를 참조 할 필요가
.
xx.x
은 컴퓨터에 설치된 Outlook 버전에 따라 다릅니다.
출처
2016-06-29 06:11:13
L42
기존 코드에 문제가있는 경우 오류와 발생하는 라인과 함께 게시하는 것이 가장 좋습니다. –