現在、Outlook v2.0を使用しています。これは本当に新しいもので、予期しない問題が発生しました。現在、私の認証があり、Outlookクライアントを問題なく作成することができます。しかし、現在250通の電子メールを持っているメールボックスのテストランを行った後、私は、このAPIが唯一の10は、OutlookのAPIのV 2.0Outlookコールのみ通話で10個のアイテムを返す
コード
を使用しているとき、誰もがこの問題に遭遇しているかどうかを調べて取得していることがわかりprivate static async Task<OutlookServicesClient> CreateOutlookClientAsync(AuthenticationContext authenticationContext)
{
OutlookServicesClient outlookClient = null;
try
{
outlookClient = new OutlookServicesClient(
new Uri(CrmPrototype.Helpers.AuthHelper.OutlookAPIEndpoint),
async() =>
await GetTokenHelperAsync(authenticationContext, CrmPrototype.Helpers.AuthHelper.OutlookAuthenticationEndpoint)
);
return outlookClient;
}
catch (Exception ex)
{
// TODO Log
return outlookClient;
}
}
private static async Task<GraphServiceClient> CreateGraphClientAsync(AuthenticationContext authenticationContext)
{
GraphServiceClient graphClient = null;
try
{
graphClient = new GraphServiceClient(
new DelegateAuthenticationProvider(
async (requestMessage) =>
{
string accessToken = await GetTokenHelperAsync(authenticationContext, CrmPrototype.Helpers.AuthHelper.OutlookAuthenticationEndpoint);
// Append the access token to the request.
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
}));
return graphClient;
}
catch (Exception ex)
{
// TODO Log
return graphClient;
}
}
private static async Task<string> GetTokenHelperAsync(AuthenticationContext context, string resourceId)
{
string accessToken = null;
try
{
X509Certificate2 certificate = new X509Certificate2(CrmPrototype.Helpers.AuthHelper.devCertPath, CrmPrototype.Helpers.AuthHelper.devCertKey, X509KeyStorageFlags.MachineKeySet);
ClientAssertionCertificate clientAssertionCert = new ClientAssertionCertificate(CrmPrototype.Helpers.AuthHelper.devClientId, certificate);
AuthenticationResult result = null;
result = await context.AcquireTokenAsync(resourceId, clientAssertionCert);
accessToken = result.AccessToken;
return accessToken;
}
catch (Exception ex)
{
// TODO Log
return accessToken;
}
}
public static async Task<IMessageCollection> GetEmails(string emailBox)
{
IMessageCollection emails = null;
AuthenticationContext authenticationContext = new AuthenticationContext(CrmPrototype.Helpers.AuthHelper.devTenant);
try
{
var outlookClient = await CreateOutlookClientAsync(authenticationContext);
var mail_Box = await outlookClient.Users[emailBox].MailFolders["Inbox"].Messages.OrderByDescending(m => m.ReceivedDateTime).ExecuteAsync();
var messages = mail_Box.CurrentPage; << only gets 10 emails at a time
foreach (var message in messages)
{
var stop = 0;
}
return emails;
}
catch (Exception ex)
{
// TODO Log
return emails;
}
}
ウォッチ名前が示すようOutlookRESTのAPI
Benoit、私はJavaScriptのページングに慣れています。これは非常に簡単です。その緩い拘束のために簡単ですが、私の頭を包み込むことができます。もう一度ありがとうございます。 – EasyE
正確には必要なものはわかりませんが、Outlook REST APIのODATAパラメータに関するこのドキュメントはhttps://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar #OdataQueryParamsが役立ちます。 –