如何从Exchange Web服务更新预约ASP.NET托管API 2.0 [英] How to Update an Appointment from Exchange Web Service Managed API 2.0 in ASP.NET

查看:146
本文介绍了如何从Exchange Web服务更新预约ASP.NET托管API 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IAM使用EWS托管API 2.0创建Appontment。它工作正常。但要更新现有的约会了。
我读,我需要预约ID以指定任命应进行编辑。但如果是ID?

下面是如何创建一个约会:

 创建约会
        昏暗任命为新EWS.Appointment(ESB)
        appointment.Subject = txtThema.Text
        appointment.Body = txtBemerkung.Text
        appointment.Start =冯
        appointment.End =双
        appointment.Location = lbRaumInfo.Text        添加与会者
        对于i = 1到emaillist.Length - 1
            appointment.RequiredAttendees.Add(的emailList(I))
        下一个        发送
        appointment.Save(EWS.SendInvitationsMode.SendToAllAndSaveCopy)


解决方案

要做到这一点的一种方式,是使用唯一ID,由SilverNinja的建议,和他说,这是不是永久性的标识,它可以被修改一次约会被移动到不同的文件夹(如果已例如​​删除等)。

要解决这个问题的方法是创建一个扩展属性,并把GUID的任命,并且它不会改变的,除非你做从另一个约会副本(毕竟它只是一个属性)

我在C#中,但我相信这是pretty易于转换为VB

 私有静态只读PropertyDefinitionBase AppointementIdPropertyDefinition =新ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings,AppointmentID,MapiPropertyType.String);
公共静态属性集属性集=新的属性集(BasePropertySet.FirstClassProperties,AppointementIdPropertyDefinition);
//设置属性的任命
 公共静态无效SetGuidForAppointement(预约预约)
{
    尝试
    {
        appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition,Guid.NewGuid()的ToString());
        appointment.Update(ConflictResolutionMode.AlwaysOverwrite,SendInvitationsOrCancellationsMode.SendToNone);
    }
    赶上(异常前)
    {
        //记录异常
    }
}//获取属性的任命
 公共静态字符串GetGuidForAppointement(预约预约)
{
    VAR的结果=;
    尝试
    {
        appointment.Load(属性集);
        的foreach(在appointment.ExtendedProperties VAR extendedProperty)
        {
            如果(extendedProperty.PropertyDefinition.Name ==AppointmentID)
            {
                结果= extendedProperty.Value.ToString();
            }
        }
    }
    赶上(异常前)
    {
     //记录异常
    }
    返回结果;
}

iam using the EWS Managed API 2.0 to create an Appontment. It works fine. But want to Update an existing Appointment, too. I read that i need the appointment ID to specify which appoint should be edited. But where is the ID?

Here is how i create an Appointment:

        'Creates the Appointment
        Dim appointment As New EWS.Appointment(esb)
        appointment.Subject = txtThema.Text
        appointment.Body = txtBemerkung.Text
        appointment.Start = Von
        appointment.End = Bis
        appointment.Location = lbRaumInfo.Text

        'Adds the Attendees
        For i = 1 To emaillist.Length - 1
            appointment.RequiredAttendees.Add(emaillist(i))
        Next

        'Sending
        appointment.Save(EWS.SendInvitationsMode.SendToAllAndSaveCopy)

解决方案

A way to do it, is to use the Unique ID as suggested by SilverNinja, and as he said that this is not permanent ID and it can be changed once the appointment is moved to different folder (like if it has been deleted for example).

A way to deal with this problem is to create an extended property, and put guid for the appointment, and it wont change unless you made a copy from another appointment (after all it is just a property)

I have it in C# , but I am sure it is pretty easy to convert to VB

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;
} 

这篇关于如何从Exchange Web服务更新预约ASP.NET托管API 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆