vb.net – 如何使用Exchange Web服务接受并向RequiredAttendees约会添加类别

vb.net – 如何使用Exchange Web服务接受并向RequiredAttendees约会添加类别,第1张

概述我正在使用ExchangeService(ExchangeVersion.Exchange2010_SP1) 我想接受并将类别添加到RequiredAttendees约会.要做到这一点,我需要找到这些约会. 我在EWS中的理解是,在具有RequiredAttendees的预约中,为每个“必需参加者”创建了一个新的会议请求. 如何访问为“所需参加者”自动创建的约会?这些会在所需的与会者日历中显示为约 我正在使用ExchangeService(ExchangeVersion.Exchange2010_SP1)

我想接受并将类别添加到requiredAttendees约会.要做到这一点,我需要找到这些约会.

我在EWS中的理解是,在具有requiredAttendees的预约中,为每个“必需参加者”创建了一个新的会议请求.

如何访问为“所需参加者”自动创建的约会?这些会在所需的与会者日历中显示为约会,以及会议请求.

我已成功对主题进行了粗略的查找(以下步骤)

>作为管理器连接到服务器
>创建约会
>设置主题
>添加所需的参加者
>保存约会
>从步骤4开始,按要求参加者连接到服务器
>在步骤3中找到具有主题的约会
>在步骤7中将类别添加到约会
>在步骤7更新约会
>在步骤7接受预约

这确实有效,但有关用户将更改主题.

我尝试将扩展属性和值添加到组织者创建的约会,然后将FindItems添加到作为必需参加者连接的约会中的扩展属性值.这不起作用.

对于我想要实现的目标,有一种首选方法吗?

谢谢

Private Shared Readonly m_organiserEmailAddress As String = "Organiser@test.com"Private Shared Readonly m_eventIDExtendedPropertyDeFinition As New ExtendedPropertyDeFinition(DefaultExtendedPropertySet.Meeting,"EventID",MAPIPropertyType.Long)'--> start herePublic Shared Function SavetoOutlookCalendar(eventCalendarItem As EventCalendarItem) As String    If eventCalendarItem.ID Is nothing Then        'new        Dim newAppointment = EventCalendarItemmapper.SaveNewAppointment(eventCalendarItem)        'set the ID        eventCalendarItem.ID = newAppointment.ID.UniqueID.ToString()        'accept the calendar item on behalf of the Attendee        EventCalendarItemmapper.AcceptAppointmentAsAttendees(newAppointment)        Return eventCalendarItem.ID    Else        'update existing appointment        Return EventCalendarItemmapper.UpdateAppointment(eventCalendarItem)    End IfEnd FunctionPrivate Shared Sub ConnectToServer(Optional autoUser As String = "")    If autoUser = "" Then        _service.Url = New Uri(ExchangeWebServicesUrl)    Else        _service.autodiscoverUrl(autoUser)    End IfEnd SubPrivate Shared Sub ImpersonateUser(userEmail As String)    _service.Credentials = New NetworkCredential(ImpersonatorUsername,ImpersonatorPassword,Domain)    _service.ImpersonatedUserID = New ImpersonatedUserID(ConnectingIDType.SmtpAddress,userEmail)End SubPrivate Shared Function SaveNewAppointment(eventCalendarItem As EventCalendarItem) As Appointment    Try        ConnectToServer(m_organiserEmailAddress)        ImpersonateUser(m_organiserEmailAddress)        Dim appointment As New Appointment(_service) With {                   .Subject = eventCalendarItem.Subject}        'add attendees        For Each attendee In eventCalendarItem.Attendees            appointment.requiredAttendees.Add(attendee.Email)        Next        'add categorIEs        For Each category In eventCalendarItem.CategorIEs            appointment.CategorIEs.Add(Globals.GetEnumDescription(category))        Next        'add EventID = 5059 as an extended property of the appointment        appointment.SetExtendedProperty(m_eventIDExtendedPropertyDeFinition,5059)        appointment.Save(SendInvitationsMode.SendOnlyToAll)        Return appointment    Catch        Throw New Exception("Can't save appointment")    End TryEnd FunctionPrivate Shared Sub AcceptAppointmentAsAttendees(appointment As Appointment)    For Each attendee In appointment.requiredAttendees        Try            ConnectToServer(attendee.Address.ToString())            ImpersonateUser(attendee.Address.ToString())            For Each a In FindRelatedAppiontments(appointment)                a.CategorIEs.Add(Globals.GetEnumDescription(CalendarItemcategory.Workshop))                a.Update(ConflictResolutionMode.AlwaysOverwrite,SendInvitationsOrCancellationsMode.SendToNone)                a.Accept(True)            Next        Catch            Throw        End Try    NextEnd SubPrivate Shared Function FindRelatedAppiontments(appointment As Appointment) As List(Of Appointment)    Dim vIEw As New ItemVIEw(1000)    Dim foundAppointments As New List(Of Appointment)    vIEw.PropertySet =        New PropertySet(New PropertyDeFinitionBase() {m_eventIDExtendedPropertyDeFinition})    'Extended Property value = 5059    Dim searchFilter = New SearchFilter.IsEqualTo(m_eventIDExtendedPropertyDeFinition,5059)    For Each a In _service.FindItems(WellKNownFoldername.Calendar,searchFilter,vIEw)        If a.ExtendedPropertIEs.Count > 0 Then            foundAppointments.Add(appointment.Bind(_service,CType(a.ID,ItemID)))        End If    Next    Return foundAppointmentsEnd Function
解决方法 有一点可以肯定的是,EWS没有任何直接的进展.
我会诚实地说,直到那一刻,我没有从内部日历到交换日历的整合工作,我的经验恰恰相反,这就是交换内部日历.

无论如何,在阅读完你的代码后,我认为你几乎就在那里.但是我建议您通过使用Streaming Notifications来捕捉到达与会者的约会并不难!
所以我会说步骤应该是这样的

>创建约会
>应用扩展属性(我建议使用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;}

>使用StreamingNotificationEvent捕获约会.在我看来,这样做的一个好方法是同时运行组织者和参加者,并抓住他们之间的约会.
为了看一个例子,我已经发布了上一个问题Multiple impersonation-threads in Exchange Web Service (EWS)的答案.如果您发现我的答案很有用,请投票支持这两个帖子的答案(在这里和那里).

我不想让你害怕,但一旦你解决了当前的问题;如果你想继续它会变得更复杂.我可以写下我如何解决会议问题,但我根本没有直接看到它,所以如果你自己编写它可能会更好.

干杯

总结

以上是内存溢出为你收集整理的vb.net – 如何使用Exchange Web服务接受并向RequiredAttendees约会添加类别全部内容,希望文章能够帮你解决vb.net – 如何使用Exchange Web服务接受并向RequiredAttendees约会添加类别所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1222282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存