问题
Gets error : The item type returned by the service (EmailMessage) isn't compatible with the requested item type (Task).
I'm trying to find the value of :
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
this is from an Email message through Exchange .WebServices. Data class . when we add values to Email attributes like "Millage " or "Billing information" - we can find these available .
I get the below error :
- 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}
I'm using the references from Microsoft docs to make the code :
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
- Any help is extremely appreciated - I'm stuck from last couple of days .
- I'm a beginner to Exchange Service class . error screenshot
回答1:
You'll need to use the Extended properties definitions for those properties to do what you trying https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidbilling-canonical-property and https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidlidmileage-canonical-property eg
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
回答2:
@ Glen please find the error screenshot below : Gets Error when trying to use extended properties definition
来源:https://stackoverflow.com/questions/60117994/vb-net-microsoft-exchange-webservices-data-task-class-find-billinginformati