与此同时,这是我的解决方法(只是相关的部分)。将多个值作为 JSON 字符串存储在$Value
属性中:
保存日历项时设置属性:
// define custom property
$extendedProperty = new EWSType_PathToExtendedFieldType();
$extendedProperty->PropertyName = 'MyCustomProperty';
$extendedProperty->PropertyType = EWSType_MapiPropertyTypeType::STRING;
$extendedProperty->DistinguishedPropertySetId = EWSType_DistinguishedPropertySetIdType::PUBLIC_STRINGS;
$request->Items->CalendarItem->ExtendedProperty = new EWSType_ExtendedPropertyType();
$request->Items->CalendarItem->ExtendedProperty->ExtendedFieldURI = $extendedProperty;
// store custom data as JSON string
$custom_data = array(
'scheduled_by' => 'staff',
'send_to' => $users_email
);
$request->Items->CalendarItem->ExtendedProperty->Value = json_encode($custom_data);
读取日历时检索属性:
// initialize the request
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ItemShape->AdditionalProperties = new EWSType_NonEmptyArrayOfPathsToElementType();
// get custom property
$extendedProperty = new EWSType_PathToExtendedFieldType();
$extendedProperty->PropertyName = 'MyCustomProperty';
$extendedProperty->PropertyType = EWSType_MapiPropertyTypeType::STRING;
$extendedProperty->DistinguishedPropertySetId = EWSType_DistinguishedPropertySetIdType::PUBLIC_STRINGS;
$request->ItemShape->AdditionalProperties->ExtendedFieldURI = array($extendedProperty);
解码响应中每个日历项的 JSON:
// get JSON data from custom property
$custom_data = json_decode($item->ExtendedProperty->Value, true);