VB .NET Microsoft.Exchange.WebServices.Data任务-类-从电子邮件中查找BillingInformation和里程值-语法

问题描述 投票:0回答:2

出现错误:服务(EmailMessage)返回的项目类型与请求的项目类型(任务)不兼容。

我正在寻找:的值

 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通过电子邮件发送的。数据类。当我们向电子邮件属性添加值时,例如“村庄”或“计费信息”-我们可以找到这些。

我收到以下错误:

-       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

  • [非常感谢您的帮助-最近几天我陷入困境。
  • 我是Exchange Service类的初学者。 error screenshot
.net vb.net exchangewebservices
2个回答
0
投票

您需要为这些属性使用扩展属性定义,以执行您尝试的https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidbilling-canonical-propertyhttps://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidmileage-canonical-property例如

 Dim PidLidBilling As new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8535,MapiPropertyType.String)
 Dim PidLidMileage As new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8534, MapiPropertyType.String)
 Dim psPropertySet As New PropertySet(BasePropertySet.FirstClassProperties)
 psPropertySet.Add(PidLidMileage)
 psPropertySet.Add(PidLidBilling)

mytask1 = Task.Bind(service1, val,psPropertySet)
Dim mileageValue As [Object] = Nothing
If mytask1.TryGetProperty(PidLidMileage, mileageValue) Then
    Console.WriteLine(mileageValue)
End If

0
投票

@ Glen,请在下面找到错误屏幕截图:Gets Error when trying to use extended properties definition

© www.soinside.com 2019 - 2024. All rights reserved.