[英]Excel Userform to get outlook display name and email from alias
我有一個帶有3個文本框和1個按鈕的用戶窗體。 我想將Outlook別名放入textbox1(txtPID),並在框2和3(txtName和txtEmail)中返回顯示類型和電子郵件
這似乎連接到Outlook並提取信息,但它沒有搜索文本框1中給定的別名
Load UsrFrmNewRep
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olGAL As Outlook.AddressList
Dim olMember As Outlook.AddressEntry
Dim olAliasName As String
Dim exchuser As Outlook.ExchangeUser
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olGAL = olNS.AddressLists("Global Address List")
olAliasName = UsrFrmNewRep.txtPID.Value
Set olMember = olGAL.AddressEntries(olAliasName)
Set exchuser = olMember.GetExchangeUser
If Not exchuser Is Nothing Then
UsrFrmNewRep.txtName.Value = exchuser.DisplayType
UsrFrmNewRep.txtEmail.Value = exchuser.PrimarySmtpAddress
End If
End Sub
我確定我沒有正確引用某些東西,只是不確定什么。
謝謝
代替使用olGAL.AddressEntries(olAliasName)
,請使用olNS.CreateRecipient(olAliasName)
/ Recipient.Resolve
/ set olMember = Recipient.AddressEntry
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.