Office 365 API OutlookServicesClient 筛选消息错误
Office 365 API OutlookServicesClient Filter Messages Error
我正在使用 OutlookServicesClient 获取消息。
我试图只获取特定日期后收到的消息,但我在此处收到错误消息。
我用来获取邮件和过滤器的代码:
public async Task<IReadOnlyList<IMessage>> GetMails(DateTime? MailsAfterDate)
{
OutlookServicesClient oc = await _OutlookAuthentificationService.GetOutlookClient();
if (oc != null)
{
try
{
var msgList = await oc.Me.Messages
.Expand(m => m.Attachments)
.Where(m => !m.DateTimeReceived.HasValue || !MailsAfterDate.HasValue || m.DateTimeReceived.Value.LocalDateTime.Ticks >= MailsAfterDate.Value.Ticks)
.ExecuteAsync();
return msgList.CurrentPage;
}
catch (Exception)
{
throw;
}
}
return null;
}
错误:无法解析 OData 请求 URL。
感谢您的帮助。
我发现这不起作用的原因:
DateTimeReceived 是一个可为 null 的日期时间,但您不能在 where 子句中使用值 属性 的 hasvalue。
没有这个函数就可以正常工作。
我正在使用 OutlookServicesClient 获取消息。 我试图只获取特定日期后收到的消息,但我在此处收到错误消息。
我用来获取邮件和过滤器的代码:
public async Task<IReadOnlyList<IMessage>> GetMails(DateTime? MailsAfterDate)
{
OutlookServicesClient oc = await _OutlookAuthentificationService.GetOutlookClient();
if (oc != null)
{
try
{
var msgList = await oc.Me.Messages
.Expand(m => m.Attachments)
.Where(m => !m.DateTimeReceived.HasValue || !MailsAfterDate.HasValue || m.DateTimeReceived.Value.LocalDateTime.Ticks >= MailsAfterDate.Value.Ticks)
.ExecuteAsync();
return msgList.CurrentPage;
}
catch (Exception)
{
throw;
}
}
return null;
}
错误:无法解析 OData 请求 URL。
感谢您的帮助。
我发现这不起作用的原因: DateTimeReceived 是一个可为 null 的日期时间,但您不能在 where 子句中使用值 属性 的 hasvalue。
没有这个函数就可以正常工作。