[英]Outlook Contacts API - Paging Results
I'm trying to display ALL the Outlook contacts for a selected account. 我正在尝试显示所选帐户的所有Outlook联系人。 When an account has a few thousand contacts, the following code only shows the first n contacts.
当一个帐户有几千个联系人时,以下代码仅显示前n个联系人。 The contactResults object has a MorePagesAvailable property and a GetNextPageAsync() method available, but I clearly do NOT know how to use them.
contactResults对象有一个MorePagesAvailable属性和一个GetNextPageAsync()方法可用,但我显然不知道如何使用它们。 Can someone please enlighten me.
有人可以赐教。
string token = (string)Session["access_token"];
string email = (string)Session["user_email"];
// Since we have the token locally from the Session, just return it here
OutlookServicesClient client = new OutlookServicesClient(new Uri("https://outlook.office.com/api/v2.0"), async () => { return token; });
client.Context.SendingRequest2 += new EventHandler<SendingRequest2EventArgs>((sender, e) => InsertXAnchorMailboxHeader(sender, e, email));
var contactResults = await client.Me.Contacts
.OrderBy(c => c.DisplayName)
.Take(2500)
.Select(c => new DisplayContact(c))
.ExecuteAsync();
foreach (DisplayContact displayContact in contactResults.CurrentPage)
System.Diagnostics.Debug.WriteLine(displayContact);
var contactResults = await client.Me.Contacts
.OrderBy(c => c.DisplayName)
.Select(c => new DisplayContact(c))
.ExecuteAsync();
while (true)
{
foreach (DisplayContact displayContact in contactResults.CurrentPage)
System.Diagnostics.Debug.WriteLine(displayContact);
if (contactResults.MorePagesAvailable)
contactResults = await contactResults.GetNextPageAsync();
else
break;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.