gpt4 book ai didi

c# - EWS 创建约会以交换额外的自定义属性

转载 作者:太空宇宙 更新时间:2023-11-03 10:43:11 30 4
gpt4 key购买 nike

我目前正在寻找一种使用 C# 将一些额外属性保存到交换约会的方法。目前我可以使用以下属性保存:

Appointment calendar = new Appointment(p_service);

calendar.Subject = calendarS5Subject;
calendar.Body = calendarS5Body;
calendar.Start = calendarS5StartDateTime;
calendar.End = calendarS5EndDateTime;
calendar.IsReminderSet = false;
calendar.Location = calendarS5Location;
calendar.Body.BodyType = BodyType.Text;

calendar.Save();

但是我希望能够存储我自己的自定义属性,例如 calendar.EventIDcalendar.Blah 。是否可以针对约会保存这些属性,然后在以后访问它们?如果能在指定窗口中全部存储为用户控件表单就更好了。我知道您可以使用类型为 AppointmentItem 的 outlook 插件来执行此操作。但是,我还没有找到一种方法来通过 Appointment 类型进行交换。

TIA。

我现在可以使用以下方式保存额外的属性:

Guid EventIDSetGUID = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");
ExtendedPropertyDefinition extendedPropertyEventID = new ExtendedPropertyDefinition(EventIDSetGUID, "EventID", MapiPropertyType.String);
calendar.SetExtendedProperty(extendedPropertyEventID, calendarS5EventID);

但是,我现在正在努力稍后再读回该属性。这在我保存额外属性后立即起作用,但如果我重新启动应用程序然后尝试读取额外属性 eventIDProp 总是返回 null。我的阅读代码:

Guid EventIDReadGUID = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");
ExtendedPropertyDefinition extendedPropertyEventIDRead = new ExtendedPropertyDefinition(EventIDReadGUID, "EventID", MapiPropertyType.String);
object eventIDProp;
if (calendar.TryGetProperty(extendedPropertyEventIDRead, out eventIDProp) && eventIDProp != calendarS5EventID)
{

}

最佳答案

您可以使用 MAPI 扩展属性来做到这一点:

    // Define MAPI extended properties
private readonly ExtendedPropertyDefinition _extendedPropEventId =
new ExtendedPropertyDefinition(
new Guid("{00020329-0000-0000-C000-000000000046}"),
"Event Identifier",
MapiPropertyType.String);

private readonly ExtendedPropertyDefinition _extendedPropBlah =
new ExtendedPropertyDefinition(
new Guid("{00020329-0000-0000-C000-000000000046}"),
"Blah",
MapiPropertyType.String);

...

// Set extended properties for appointment
calendar.SetExtendedProperty(_extendedPropEventId, "custom EventID value");
calendar.SetExtendedProperty(_extendedPropBlah, "custom Blah value");

...

// Bind to existing item for reading extended properties
var propertySet = new PropertySet(BasePropertySet.FirstClassProperties, _extendedPropEventId, _extendedPropBlah);
var calendar = Appointment.Bind(p_service, itemId, propertySet);
if (calendar.ExtendedProperties.Any(ep => ep.PropertyDefinition.PropertySetId == _extendedPropEventId.PropertySetId))
{
// Add your code here...
}

关于c# - EWS 创建约会以交换额外的自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24526704/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com