none
Error saving a recurrence in the Exchange API RRS feed

  • Question

  • I'm trying to use Exchange API recurrence but this one giving error when saving, it gives the following error: "An exception of type 'Microsoft.Exchange.WebServices.Data.ServiceResponseException' occurred in Microsoft.Exchange.WebServices.dll but was not handled In user code ", below the detailed error:

    _____________________________________________________________________________________________________

    Microsoft.Exchange.WebServices.Data.ServiceResponseException was unhandled by user code
      HResult=-2146233088
      Message=One occurrence of the recurring calendar item overlaps with another occurrence of the same calendar item.
      Source=Microsoft.Exchange.WebServices
      StackTrace:
           em Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
           em Microsoft.Exchange.WebServices.Data.ServiceResponse.ThrowIfNecessary()
           em Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
           em Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling)
           em Microsoft.Exchange.WebServices.Data.ExchangeService.CreateItem(Item item, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
           em Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode)
           em Microsoft.Exchange.WebServices.Data.Appointment.Save(SendInvitationsMode sendInvitationsMode)
           em AgendamentoDeSala.Web.tstrecursivo.recorrenciaPorSemana(List`1 dias, Int32 acada)
           em AgendamentoDeSala.Web.tstrecursivo.Salvar_Click(Object sender, EventArgs e)
           em System.Web.UI.WebControls.Button.OnClick(EventArgs e)
           em System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
           em System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
           em System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
           em System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
           em System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException:

    Code snippet:

          List<DayOfTheWeek> diassemanas = new List<DayOfTheWeek>();
                            diassemanas.Add(DayOfTheWeek.Sunday);
                            diassemanas.Add(DayOfTheWeek.Monday);
                            diassemanas.Add(DayOfTheWeek.Tuesday);
                            diassemanas.Add(DayOfTheWeek.Wednesday);
                            diassemanas.Add(DayOfTheWeek.Thursday);
                            diassemanas.Add(DayOfTheWeek.Friday);
                            diassemanas.Add(DayOfTheWeek.Saturday);

                            List<DayOfTheWeek> semanas = new List<DayOfTheWeek>();

                            for (int i = 0; i < dias.Count; i++)
                            {
                                semanas.Add(diassemanas[dias[i]]);
                            }
                            DayOfTheWeek[] diasSelecionados = semanas.ToArray();     
                            appointment.Recurrence = new Recurrence.WeeklyPattern(appointment.Start.Date, intervalo, diasSelecionados);
                            appointment.Recurrence.StartDate = appointment.Start.Date;
                            appointment.Recurrence.EndDate = Convert.ToDateTime(dataf.ToString("yyyy-MM-dd") + dataf.ToString(" HH:mm:ss"));

                            //   appointment.Recurrence.EndDate = new DateTime(ano2, mes2, dia2);

                            // Save the recurring series.
                            appointment.Save(SendInvitationsMode.SendToNone);



    Matheus N. Camargo

    Tuesday, March 7, 2017 6:44 PM

All replies

  • It looks like your trying to create a Daily Recurrence with a Weekly Recurrence pattern it doesn't make logical sense, the error is telling you the following

    "One occurrence of the recurring calendar item overlaps with another occurrence of the same calendar item"

    I can see that happening in your logic because you don't set the Start and End Day of the appointment or the Timezone settings but in that instance a Daily Recurrence is a better idea.

    Wednesday, March 8, 2017 3:01 AM
  •     appointment.Recurrence.StartDate = appointment.Start.Date;                      
        appointment.Recurrence.EndDate = Convert.ToDateTime(dataf.ToString("yyyy-MM-dd") + dataf.ToString(" HH:mm:ss"));
    Is not that how to start and end the recurrence?


    Matheus N. Camargo


    Wednesday, March 8, 2017 11:31 AM
  • Yes but you don't specify a Start and EndTime for the appointment itself and you also don't specify the TimeZone these are generally all critical props, what the error is telling you is that your trying to create a Weekly recurrence that occurs every day and within the Recurrence range one of those appointment are overlapping. So one solution would be to use a daily reoccurrence which makes more sense given what your trying to do (eg why are you trying to use a Weekly recurrence instead of daily when the appointment is recurring every day).
    Thursday, March 9, 2017 2:42 AM