出现错误:服务(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/office/client-developer/outlook/mapi/pidlidbilling-canonical-property和https://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
@ Glen,请在下面找到错误屏幕截图:Gets Error when trying to use extended properties definition