我正在使用 EWSJavaAPI 在 Exchange Server 中创建任务,但我没有得到任何使用相同 api 获取任务的参考。下面是我的代码添加任务:
Task t=new Task(service);
t.setSubject("Task to test in JAVA");
t.setBody(MessageBody.getMessageBodyFromText("Test body from JAVA"));
t.setStartDate(startTime);
t.setDueDate(endTime);
t.save();
我尝试下面的代码来获取任务,但这不起作用:
//Create the extended property definition.
ExtendedPropertyDefinition taskCompleteProp = new
ExtendedPropertyDefinition(DefaultExtendedPropertySet.Task, 0x0000811C,
MapiPropertyType.Boolean);
//Create the search filter.
SearchFilter.IsEqualTo filter = new
SearchFilter.IsEqualTo(taskCompleteProp, false);
//Get the tasks.
FindItemsResults<Item> tasks =
service.findItems(WellKnownFolderName.Tasks, filter, new ItemView(50));
for(Item task:tasks){
System.out.println(task.getSubject());
System.out.println(task.getBody());// getting error at this line
System.out.println(task.getReminderMinutesBeforeStart());
System.out.println(task.getReminderDueBy());
System.out.println("=======================");
}
task.getBody() 错误;microsoft.exchange.webservices.data.ServiceObjectPropertyException:您必须先加载或分配此属性,然后才能读取其值。在 microsoft.exchange.webservices.data.PropertyBag.getPropertyValueOrException(Unknown Source) 在 microsoft.exchange.webservices.data.PropertyBag.getObjectFromPropertyDefinition(Unknown Source) 在 microsoft.exchange.webservices.data.Item.getBody(Unknown Source) 在 MSExchangeEmailService .readTask(MSExchangeEmailService.java:146) 在 MSExchangeEmailService.main(MSExchangeEmailService.java:224)
请帮忙,这是获取任务的正确方法吗?