从Outlook地址列表vba获取经理信息 [英] get manager info from Outlook Address List vba
本文介绍了从Outlook地址列表vba获取经理信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码打开全局地址列表"窗口,以在列表中选择一个联系人.
I'm using the below code to open the Global Address List window to select a contact in the list.
对于选定的联系人,我也想获得经理的姓名.但是,我似乎无法使其正常工作.
For the contact that is selected, I'd like to get the Manager name as well. However, I can't seem to get it to work.
有什么建议吗?
Private Sub accountManagerName_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim CDOSession, cdoAddressBook, olkRecipients, objAE
On Error Resume Next
Set CDOSession = CreateObject("MAPI.Session")
' Change the name of your Outlook profile as needed.
CDOSession.Logon "", "", False, False
Set olkRecipients = CDOSession.AddressBook(, "Global Address List", 0, False)
For Each objAE In olkRecipients
accountManagerName.Text = objAE.name
'ccManager.Caption = objAE.Manager.name
Next
Set olkRecipients = Nothing
CDOSession.Logoff
Set CDOSession = Nothing
End Sub
推荐答案
我能够弄清楚!
只需将接收者对象转换为地址输入对象,然后从那里获取管理器信息,
这也可以通过使用objAE.addressEntry.Manager
来完成!
simply had to convert the recipient object into an addressentry object and pull the manager info from there,
this can be done by using objAE.addressEntry.Manager
too!
Private Sub accountManagerName_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
On Error Resume Next
Set CDOSession = CreateObject("MAPI.Session")
' Change the name of your Outlook profile as needed.
CDOSession.Logon "", "", False, False
If Err.Number <> 0 Then MsgBox "Please ensure you have Outlook open.", , "ERROR"
Set olkRecipients = CDOSession.AddressBook(, "Select Account Manager", 0, False)
For Each objAE In olkRecipients
accountManagerName.Text = objAE.name
AMfullName = objAE.name
'convert Recipient object to AddressEntry object using the recipient ID
Set objAE2 = CDOSession.GetAddressEntry(objAE.ID)
AMfirstName = objAE2.fields(18)
AMlastName = objAE2.fields(22)
AMmanagerName = objAE2.Manager
' Debug.Print AMfirstName
' Debug.Print AMlastName
' Debug.Print AMmanagerName
Next
ccAMmanager.Caption = AMmanagerName
ccUserManager.Caption = getName("mgrname")
ccAMmanager.Activate
Set olkRecipients = Nothing
CDOSession.Logoff
Set CDOSession = Nothing
End Sub
这篇关于从Outlook地址列表vba获取经理信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文