我曾尝试在使用EWS的约会中使用扩展属性,但我似乎无法再次找到约会。 set属性部分等于此问题中显示的部分:
How to Update an Appointment from Exchange Web Service Managed API 2.0 in ASP.NET
当我尝试检索约会时,我遵循了以下示例:
http://msdn.microsoft.com/en-us/uc14trainingcourse_5l_topic3#_Toc254008129 http://msdn.microsoft.com/en-us/library/exchange/dd633697(v=exchg.80).aspx
但是当我查找时,我从未收到任何约会。
以下是查找的代码:
ItemView view = new ItemView(10);
// Get the GUID for the property set.
Guid MyPropertySetId = new Guid("{" + cGuid + "}");
// Create a definition for the extended property.
ExtendedPropertyDefinition extendedPropertyDefinition =
new ExtendedPropertyDefinition(MyPropertySetId, "AppointmentID", MapiPropertyType.String);
view.PropertySet =
new PropertySet(
BasePropertySet.IdOnly,
ItemSchema.Subject,
AppointmentSchema.Start,
AppointmentSchema.End, extendedPropertyDefinition);
SearchFilter filter = new SearchFilter.Exists(extendedPropertyDefinition);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, filter,
view);
非常感谢任何帮助。
修改 当我尝试创建属性时,如文档所示:
http://msdn.microsoft.com/en-us/library/exchange/dd633654(v=exchg.80).aspx
它失败了,因为它是一个Guid我添加为属性值。 : - /
再次修改 刚刚尝试获取今天的所有约会,并从我刚创建的约会中获取该属性,并且它与我存储的内容相同,没有{},因此它必须与过滤器一起使用。
再次编辑* 它与
有关 ExtendedPropertyDefinition extendedProperty = new ExtendedPropertyDefinition(
如果我使用:
new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.Appointment,
"AppointmentID",
MapiPropertyType.String);
它会查找所有具有属性的约会,但如果我搜索特定的约会:
Guid MyPropertySetId = new Guid("{" + cGuid + "}");
ExtendedPropertyDefinition extendedProperty =
new ExtendedPropertyDefinition(
MyPropertySetId,
"AppointmentID",
MapiPropertyType.String);
然后什么都没找到。
答案 0 :(得分:22)
这是一个示例代码,如何使用customid创建约会并在保存后找到它:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.AutodiscoverUrl("someone@somewhere.com");
ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmenId", MapiPropertyType.String);
Guid testid = Guid.NewGuid ();
Appointment appointment = new Appointment(service);
appointment.Subject = "Test";
appointment.Start = DateTime.Now.AddHours(1);
appointment.End = DateTime.Now.AddHours(2);
appointment.SetExtendedProperty(def, testid.ToString());
appointment.Save(WellKnownFolderName.Calendar);
SearchFilter filter = new SearchFilter.IsEqualTo(def, testid.ToString());
FindItemsResults<Item> fir = service.FindItems(WellKnownFolderName.Calendar, filter, new ItemView(10));
希望这可以帮助你...
答案 1 :(得分:0)
您在收件箱中搜索约会。那里你永远找不到它们。请尝试在日历中搜索。
答案 2 :(得分:0)
这是一个将guid作为扩展属性并根据guid获取约会的示例。
private static readonly PropertyDefinitionBase AppointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String);
public static PropertySet PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointementIdPropertyDefinition);
//Setting the property for the appointment
public static void SetGuidForAppointement(Appointment appointment)
{
try
{
appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition, Guid.NewGuid().ToString());
appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
}
catch (Exception ex)
{
// logging the exception
}
}
//Getting the property for the appointment
public static string GetGuidForAppointement(Appointment appointment)
{
var result = "";
try
{
appointment.Load(PropertySet);
foreach (var extendedProperty in appointment.ExtendedProperties)
{
if (extendedProperty.PropertyDefinition.Name == "AppointmentID")
{
result = extendedProperty.Value.ToString();
}
}
}
catch (Exception ex)
{
// logging the exception
}
return result;
}