- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的公司在 Office 365 下。我的目标是在我的 asp .net MVC 应用程序中检索用户的 Outlook 建议联系人(自动完成列表中显示的联系人)。该网站配置为使用 Windows 身份验证自动登录,我不想询问用户他的凭据。
我必须尝试使用 Exchange Web 服务检索建议的联系人,但我只能使用以下代码成功检索“真实”联系人:
public List<Contact> GetContacts()
{
ContactsFolder.Bind(this._service, WellKnownFolderName.Contacts);
ItemView itemView = new ItemView(1000);
itemView.PropertySet = new PropertySet(BasePropertySet.IdOnly, new PropertyDefinitionBase[4]
{
(PropertyDefinitionBase) ContactSchema.DisplayName,
(PropertyDefinitionBase) ContactSchema.Surname,
(PropertyDefinitionBase) ContactSchema.GivenName,
(PropertyDefinitionBase) ContactSchema.EmailAddress1
});
FindItemsResults<Item> items = this._service.FindItems(WellKnownFolderName.Contacts, (ViewBase) itemView);
List<Contact> list = new List<Contact>();
foreach (Item obj in items)
{
if (obj is Contact)
list.Add(obj as Contact);
}
return list;
}
然后,我尝试使用 People Api of Office 365 REST API但我不知道如何在不询问用户登录名/密码的情况下调用电话。这是一个尝试示例(如果我不使用代理,我会收到一个 HTTP 407 Error ):
public async Task Try()
{
var proxy = WebRequest.GetSystemWebProxy();
proxy.Credentials = new NetworkCredential("foo", "1234");
// Now create a client handler which uses that proxy
HttpClient client = null;
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
Proxy = proxy,
PreAuthenticate = true,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("foo@foo.com", "1234")
};
var httpClient = new HttpClient(httpClientHandler);
var result = await httpClient.GetAsync("https://outlook.office.com/api/beta/me/people");
var stringContent = await result.Content.ReadAsStringAsync();
}
最佳答案
我的意思是您没有在正确的文件夹中查找。根据我通过谷歌搜索所见,建议的联系人不在联系人 目录中,而是在建议的联系人 中。在您的 EWS 示例中,您正在查找联系人...参见 this discussion .另请参阅 this guy post ,他设法使用 EWS 和 powershell 访问建议的联系人文件夹,因此毫无疑问这对于 C# 和 EWS .NET SDK 是可行的。我的建议是继续尝试您的示例 1。
我要强调的是,您的请求应该被授权访问 Exchange Web 服务(代码示例 1)或 outlook REST API(代码示例 2)。
在示例 1 中,我们看不到 _service
字段是如何实例化的,但我敢打赌,有一段代码或多或少看起来像下面的行,因此您可以请求 EWS。
ExchangeService service = new ExchangeService();
service.Credentials = new OAuthCredentials(token);
service.Url = new Uri(ewsUrl);
token
可能会被 Outlook REST API 重用,尝试将其设置在 httpClient
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "您的 Oauth token ");
现在您的请求应该已获得授权,但您仍然遇到代理问题。我敢打赌,这只会在您的组织内发生,因为您的 IT 设置了代理。您可能不会在生产中需要它。在本地开发时,您可以使用调试语句使其工作。
#if DEBUG
IWebProxy webProxy = System.Net.WebRequest.DefaultWebProxy;
if (webProxy!=null && !webProxy.IsBypassed(new Uri(endpoint)))
{
client.Proxy = webProxy;
}
#endif
关于c# - 检索 Outlook 建议的联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35911745/
对于我的应用程序的一部分,我需要在选择该选项时显示所有联系人的列表(带有电话号码)。 这是按下按钮时调用的 Activity : package com.example.prototype01; im
我正在尝试使用 Google Contact API (C#) 将“生日”值添加到 Google Contact。谁能帮我解决这个问题。 我正在使用 Google 数据 API 设置 (1.4.0.2
如何使用 Google Contact API (c#) 在 Google Contact 中创建新的“自定义字段”? 我用过: ExtendedProperty obj_ExtendedProper
我正在 iPhone 应用程序中使用地址簿框架,并且我想获取项目公司名称。我在 AddressBookUI_Framework.pdf 中找不到此信息,有人可以解释一下吗? 问候 AddressBoo
我正在开发一个数据库来管理一家小公司的客户数据。客户是公司和机构(学校等),当然还有人/联系人。会有更多的范围及时添加,但现在我正在寻找关于核心设计本身的任何输入,如果有任何我在这里遗漏的东西可能会导
我正在使用 Swift Contacts 并尝试确定是否可以将 contacts.phoneNumbers 转换为 NSDictionary?即可以通过以下方式在 contacts.phoneNumb
我想要我的联系人的 ListView。我使用谷歌示例代码。问题是我一遍又一遍地获得相同的联系人: 吉姆 吉姆 吉姆 吉姆 吉姆 安娜 安娜 安娜 安娜 ... 如何获得我的联系人的 DISTINCT
对于我的应用程序,我需要导入 Gmail 地址簿,我可以按照“Gmail Contact API”进行操作。 最近 Gmail 添加了一些不属于 xml 的新字段(即生日、网站等)。 gmail ap
在 NetSuite 中编辑记录时,我有一个按钮需要能够获取所有联系人的名字、姓氏、电子邮件和可能的 Angular 色,以便我可以将其附加到我已经编写的其他代码中。我似乎无法弄清楚如何提取与记录关联
我们需要一种使用 Delphi/Pascal 代码读取(并且可以选择写入).vcf 文件的方法。带有源代码的免费库将是完美的。 最佳答案 AceVCard是delphi 2009的免费开放组件,兼容V
我正在模拟一个电话簿,其中有 ArrayList 。如何覆盖toString()函数为了拥有像这样的东西,我们正在做 System.out.println(phonebook) ? Name: nam
我正在尝试构建一个搜索 XML 表达式以与 Java 中的 Exchange Web 服务一起使用。我试图实现的是我可以通过电子邮件地址搜索所有联系人。我已经浏览了他们的文档,但未能使其正常工作。这是
我有一个项目正在进行,我想自动发送 SMS,并有时间和日期将 SMS 推送给特定的联系人。那么如何以简洁高效的方式从手机中提取联系人呢?基本上我希望用户按下一个按钮,然后应用程序转到联系人列表,然后用
我有一个表格 View ,显示所有联系人都使用 RealmSwift。如何使用谓词按电话号码过滤 Realm 联系人? class Contact: Object { @obj
我正在尝试使用 CNContactVCardSerialization 将联系人保存为 vcf,效果相对较好。我确实发现苹果不包含注释或图像作为 VCF 的一部分。我确实使用了 stackoverfl
我正在读取手机中的所有联系人,如下所示: Cursor cursor = MainApp.get().getContentResolver().query( C
我有具有 list 权限的应用程序 我的 Activity 尝试加载联系人: eDeviceRecordsLoader contactsLoader = new eDeviceRec
我正在尝试编辑组标题和注释, 编辑标题适用于系统组 和用户创建的组, 虽然注释列只有在系统组(例如“联系人”、“ friend ”、“家庭”、“同事”)时才会保留,我假设它不会为用户创建的组保存注释,
在我的应用中,我想将联系人与其他数据相关联。对联系人的引用必须尽可能持久,否则关联的数据将变成垃圾。 首先,我应该使用 ContactsContract.Contact.LOOKUP_KEY 访问聚合
我正在做一个应用程序,因为我显示从设备到 ListView 的所有联系人(姓名、号码、图像)。我想使用工具栏搜索从 ListView 中搜索联系人。我添加了工具栏搜索,但我不知道如何从列表中过滤联系人
我是一名优秀的程序员,十分优秀!