【发布时间】:2021-07-28 20:57:32
【问题描述】:
我在我的项目中使用这个库 (Microsoft Graph .NET client library) 从我的邮箱中检索电子邮件。但是,当我尝试按 createdDateTime 或正文过滤邮箱中的邮件时,我收到“错误请求”错误。以下是我的要求:
private static IMailFolderMessagesCollectionPage GetMessages(string subject, int count)
{
return new graphServiceClient.Me.MailFolders.Inbox.Messages.Request().Filter($"subject eq '{subject}' and createdDateTime gt '{DateTime.Now.AddMinutes(-10)}'").Top(count).GetAsync().Result;
}
private static IMailFolderMessagesCollectionPage GetMessages(string subject, string bodyPart, int count)
{
return new graphServiceClient.Me.MailFolders.Inbox.Messages.Request().Filter($"subject eq '{subject}' and body contains '{bodyPart}'").Top(count).GetAsync().Result;
}
我使用的 Microsoft Graph API 和库本身是否支持按 createdDateTime 和正文过滤电子邮件(消息)?如果是这样,有谁知道问题出在哪里?
UPD
原来我有错误的请求来按正文过滤电子邮件。下面是正确的查询,但我还找不到该查询的任何字母。也许有人会觉得它有用。
private static IMailFolderMessagesCollectionPage GetMessages(string subject, string bodyPart, int count)
{
return new graphServiceClient.Me.MailFolders.Inbox.Messages.Request().Filter($"subject eq '{subject}' and contains(body/content, '{bodyPart}')").Top(count).GetAsync().Result;
}
【问题讨论】:
标签: c# microsoft-graph-api microsoft-graph-sdks