0
사용자가 userform을 클릭 할 selectRec
단추가 있습니다.VBA를 사용하여 Outlook 주소록 대화 상자 시작
해당 버튼을 클릭하면 Outlook 주소록 대화 상자에 수신자를 추가하라는 메시지가 표시됩니다. 수신자는 ListBox1
에 추가됩니다. 아래의 코드는 하나의 수신자 만 추가 할 수 있도록 허용합니다. oDialog.recipients.Item
배열의 첫 번째 항목에만 액세스하기 때문입니다. 나는 (그들이 원하는만큼 그들이 많은 이메일 주소를 추가 할 수있는) 당신은 그냥 사용할 필요가
Private Sub selectRec_Click()
Dim olApp As Outlook.Application
Dim oDialog As SelectNamesDialog
Dim oGAL As AddressList
Dim myAddrEntry As AddressEntry
Dim exchUser As Outlook.ExchangeUser
Dim AliasName As String
Dim FirstName As String
Dim LastName As String
Dim EmailAddress As String
Set olApp = GetObject(, "Outlook.Application")
Set oDialog = olApp.Session.GetSelectNamesDialog
Set oGAL = olApp.GetNamespace("MAPI").AddressLists("Global Address List")
With oDialog
.AllowMultipleSelection = True
.InitialAddressList = oGAL
.ShowOnlyInitialAddressList = True
If .Display Then
AliasName = oDialog.recipients.Item(1).Name
Set myAddrEntry = oGAL.AddressEntries(AliasName)
Set exchUser = myAddrEntry.GetExchangeUser
If Not exchUser Is Nothing Then
FirstName = exchUser.FirstName
LastName = exchUser.LastName
EmailAddress = exchUser.PrimarySmtpAddress
End If
ListBox1.AddItem (EmailAddress)
End If
End With
Set olApp = Nothing
Set oDialog = Nothing
Set oGAL = Nothing
Set myAddrEntry = Nothing
Set exchUser = Nothing
End Sub