简体   繁体   English

使用 VBA 从打开的 Outlook 属性中检索联系信息,例如员工 ID

[英]Retrieve Contact Information such as Employee Id from Open Outlook Properties using VBA

Whenever we right click on an Email Address, and click on Open Outlook Properties, a contact card is open as shown, I want to extract Employee ID and other details from Employee Info tab through VBA, I am able to extract First name etc by using following code.每当我们右键单击 Email 地址,然后单击打开 Outlook 属性时,如图所示打开了一个联系人卡片,我想通过 Z6E3EC7E6A9F6007B4838FC0EE793A 从 Employee Info 选项卡中提取员工 ID 和其他详细信息,以提取名字等以下代码。

Set OutRecipients = OutMail.Recipients.Add(EmailAddress)
OutRecipients.Resolve
Name = OutRecipients.AddressEntry.GetExchangeUser.Name
FirstName = OutRecipients.AddressEntry.GetExchangeUser.FirstName
LastName = OutRecipients.AddressEntry.GetExchangeUser.LastName
Alias = OutRecipients.AddressEntry.GetExchangeUser.Alias
JobTitle = OutRecipients.AddressEntry.GetExchangeUser.JobTitle
Department = OutRecipients.AddressEntry.GetExchangeUser.Department
PrimarySmtpAddress = OutRecipients.AddressEntry.GetExchangeUser.PrimarySmtpAddress

Output_sh.Cells(lCnt, 1) = Name
Output_sh.Cells(lCnt, 2) = FirstName
Output_sh.Cells(lCnt, 3) = LastName
Output_sh.Cells(lCnt, 4) = Alias
Output_sh.Cells(lCnt, 5) = JobTitle
Output_sh.Cells(lCnt, 6) = Department
Output_sh.Cells(lCnt, 7) = PrimarySmtpAddress

Open Outlook properties打开 Outlook 属性

Employee info员工信息

The AddressEntry.GetExchangeUser method returns an ExchangeUser object that represents the AddressEntry if the AddressEntry belongs to an Exchange AddressList object such as the Global Address List (GAL) and corresponds to an Exchange user.如果AddressEntry属于诸如全局地址列表 (GAL) 之类的 Exchange AddressList object 并且对应于 Exchange 用户,则AddressEntry.GetExchangeUser方法返回一个ExchangeUser object 表示AddressEntry

If you take a look at the ExchangeUser properties you may find all of them.如果您查看ExchangeUser属性,您可能会找到所有这些属性。

ExchangeUser is derived from the AddressEntry object, and is returned instead of an AddressEntry when the caller performs a query interface on the AddressEntry object. ExchangeUser 派生自 AddressEntry object,并在调用者对 AddressEntry object 执行查询接口时返回而不是 AddressEntry。

This object provides first-class access to properties applicable to Exchange users such as FirstName , JobTitle , LastName , and OfficeLocation .此 object 提供对适用于 Exchange 用户的属性的一流访问,例如FirstNameJobTitleLastNameOfficeLocation You can also access other properties specific to the Exchange user that are not exposed in the object model through the PropertyAccessor object.您还可以通过PropertyAccessor object 访问未在 object model 中公开的特定于 Exchange 用户的其他属性。 Note that some of the explicit built-in properties are read-write properties.请注意,一些显式的内置属性是读写属性。 Setting these properties requires the code to be running under an appropriate Exchange administrator account;设置这些属性需要代码在适当的 Exchange 管理员帐户下运行; without sufficient permissions, calling the ExchangeUser.Update method will result in a "permission denied" error.如果没有足够的权限,调用ExchangeUser.Update方法将导致“权限被拒绝”错误。 You can use MFCMAPI or OutlooSpy utilities for exploring low-level properties.您可以使用MFCMAPIOutlooSpy实用程序来探索低级属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM