首页 > 解决方案 > VB .NET Microsoft.Exchange.WebServices.Data 任务 - 类 - 从电子邮件中查找 BillingInformation 和里程值 - 语法

问题描述

获取错误:服务返回的项目类型 (EmailMessage) 与请求的项目类型 (Task) 不兼容。

我试图找到的价值:

 Dim value As String
 Dim service1 As ExchangeService = New 
 ExchangeService(ExchangeVersion.Exchange2013, easternZone)
 service1.Credentials = New WebCredentials(UserID, Password)
 service1.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx") 

 Dim findResults As FindItemsResults(Of Item) = service1.FindItems(folderID1, unReadFilter, New ItemView(50))

 For Each item As Item In findResults
    Dim val = item.Id.ToString()
   mytask1 = Task.Bind(service1, val)
   value = mytask1.Mileage.ToString() Next

这是来自通过 Exchange .WebServices 的电子邮件消息。数据类。当我们为“Millage”或“Billing information”等电子邮件属性添加值时 - 我们可以找到这些可用的。

我收到以下错误:

-       ex  {"The item type returned by the service (EmailMessage) isn't compatible with the requested item type (Task)."}  System.Exception {Microsoft.Exchange.WebServices.Data.ServiceLocalException}

我正在使用 Microsoft 文档中的参考来制作代码:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.task?view=exchange-ews-api

https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.task.billinginformation?view=exchange-ews-api#Microsoft_Exchange_WebServices_Data_Task_BillingInformation

https://docs.microsoft.com/en-us/dotnet/api/microsoft.exchange.webservices.data.task.bind?view=exchange-ews-api

标签: .netvb.netexchangewebservices

解决方案


@Glen 请在下面找到错误截图: 尝试使用扩展属性定义时出现错误


推荐阅读