我正在构建一个加载项,除了帐户拥有的联系人列表之外,它还应该获取当前项目(消息)中使用的联系人(收件人、发件人、抄送和密件抄送)。
根据 documentation ,尽管我在通讯录中有联系人,并且正在阅读带有发件人电子邮件的消息,但以下指令给了我零联系人。
var contacts = Office.context.mailbox.item.getEntities().contacts;
此列表可通过 open graph APIs 访问,我想知道是否也可以使用 Office 加载项的 Office 对象在本地访问它
最佳答案
Office Js 不提供 API 来获取帐户中的联系人列表。 但是您可以使用 authentication APIs 从 Outlook 获取身份验证 token ,然后使用这个token获取Graph token来与Graph APIs进行交互并获取 list of contacts
Office.context.auth.getAccessTokenAsync(function (result) {
if (result.status === "succeeded") {
// Use this token to call Web API
var ssoToken = result.value;
// Now send this token to your server and acquire a Graph token
// Server can talk to Graph APIs and get contacts to display
} else {
// Handle error
}
});
关于outlook - 是否可以使用 Office Add In 以编程方式访问 Outlook 中的联系人列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53904126/