针对复杂类型的O365 API过滤器

时间:2014-07-15 19:13:29

标签: odata office365 exchangewebservices outlook-restapi

从特定发件人电子邮件地址收到电子邮件的查询是什么?

我尝试过滤"地址" " From"的属性财产,这是一个"收件人"复杂类型根据O365 Microsoft.Exchange.Services.OData.Model命名空间。

复杂类型的OData过滤就像这样

/Me/Inbox/Messages?$filter=From/Address eq 'email@email.com'

但是,这会返回以下错误:

"error": {
    "code": "ErrorInvalidProperty",
    "message": "The property 'Address' is invalid.",
    "innererror": {
        "message": "The property 'Address' is invalid.",
        "type": "Microsoft.Exchange.Services.OData.InvalidPropertyException",
        "stacktrace": "   at Microsoft.Exchange.Services.OData.SchemaExtensions.ResolveProperty(Schema schema, String propertyName)\r\n   at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.GetPropertyProvider(QueryNode queryNode)\r\n   at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.ConvertFilterNode(QueryNode queryNode)\r\n   at Microsoft.Exchange.Services.OData.Model.EwsQueryAdapter.GetRestriction()\r\n   at Microsoft.Exchange.Services.OData.Model.MessageProvider.Find(String parentFolderId, MessageQueryAdapter queryAdapter)\r\n   at Microsoft.Exchange.Services.OData.Model.FindMessagesCommand.InternalExecute()\r\n   at Microsoft.Exchange.Services.OData.ODataCommand`2.Execute()\r\n   at Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan queueAndDelayTime, TimeSpan totalTime)"
    }
}

2 个答案:

答案 0 :(得分:0)

我遇到了同样的错误,即复杂类型的属性无效。

似乎交换服务不支持复杂类型过滤。

您可以尝试将所有邮件发送到本地存储并进行过滤。

答案 1 :(得分:0)

电子邮件地址是一种复杂的类型,但它被列为可过滤的(https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesMessage),这意味着以下内容应该有效......

https://outlook.office365.com/api/v1.0/me/messages?$ filter =来自/ EmailAddress /地址eq'email@email.com'

但是,我遇到这个问题,它似乎只是返回空白值,而以下工作......

https://outlook.office365.com/api/v1.0/me/messages?$ filter = From / EmailAddress / Name eq'Joe Bloggs'

因此,API可能存在错误,或者电子邮件地址可能需要采用不同的格式。