locked
C# EWS and AppointmentItem error RRS feed

  • Question

  • HI,

    I try to develop event receiver who I create AppointmentItem to Outlook whit EWS (this work good) but if I want to this item update, than I get error: "StartTimeZone required when setting the Start, End, IsAllDayEvent, or Recurrence properties. You must load or assign this property before attempting to update the appointment."

    my code:

    Appointment appointmentItem = Appointment.Bind(service, new ItemId(oListItem["AppID"].ToString()));
                                            if (appointmentItem != null)
                                            {
                                                appointmentItem.Subject = oListItem.Title.ToString();
    
                                                appointmentItem.Start = Convert.ToDateTime(item["Start"]);
                                                appointmentItem.End = Convert.ToDateTime(item["End"]);
    
                                                appointmentItem.Location = oListItem["Location"].ToString();
                                                appointmentItem.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
                                            }

    I don't understad who is the problem.

    Please help!

    Thanks,

    Mykie

    Friday, August 30, 2013 12:44 PM

Answers

  • Hello Mykie,

    the method appears to want a timezone info for your appointment. Either you request it, adding a propertyset that requests the StartTimeZone and EndTimeZone properties (recommended), or you set the values within your "if" segment.

    If you do not request these properties, your appointment will have null for both properties. Those two properties have the type "System.TimeZoneInfo", System.TimeZoneInfo.local ought to get your your current timezone, so if you always are in only one timezone, you could just set

    appointmentItem.StartTimeZone
    appointmentItem.EndTimeZone

    manually.

    Being neat, you should request the properties, by creating a new propertyset, adding the two properties to it and including it in the bind operation.

    Cheers,
    Fred

    Edit:
    Here's the api's opinion on Appointment
    Here's the api's opinion on AppointmentSchema
    Here's the api's opinion on PropertySet


    There's no place like 127.0.0.1


    • Edited by FWN Friday, August 30, 2013 1:07 PM
    • Marked as answer by Mykie89 Monday, September 2, 2013 4:09 PM
    Friday, August 30, 2013 1:04 PM

All replies

  • Hello Mykie,

    the method appears to want a timezone info for your appointment. Either you request it, adding a propertyset that requests the StartTimeZone and EndTimeZone properties (recommended), or you set the values within your "if" segment.

    If you do not request these properties, your appointment will have null for both properties. Those two properties have the type "System.TimeZoneInfo", System.TimeZoneInfo.local ought to get your your current timezone, so if you always are in only one timezone, you could just set

    appointmentItem.StartTimeZone
    appointmentItem.EndTimeZone

    manually.

    Being neat, you should request the properties, by creating a new propertyset, adding the two properties to it and including it in the bind operation.

    Cheers,
    Fred

    Edit:
    Here's the api's opinion on Appointment
    Here's the api's opinion on AppointmentSchema
    Here's the api's opinion on PropertySet


    There's no place like 127.0.0.1


    • Edited by FWN Friday, August 30, 2013 1:07 PM
    • Marked as answer by Mykie89 Monday, September 2, 2013 4:09 PM
    Friday, August 30, 2013 1:04 PM
  • Thanks Fred, for your answer, but I use ExchangeVersion.Exchange2007_SP1 version and I get error if I set this properties: The property EndTimeZone is valid only for Exchange Exchange2010 or later versions.
    Sunday, September 1, 2013 10:42 AM
  • Hello Mykie,

    in that case, the only thing that comes to mind is to check the information of your ExchangeService object: Did you specify the requested Exchange Version and the Time-Zone.

    If that's not it, then I believe your best bet to find out what's wrong is named "Glen" :) (and I'll be interested in the solution as well) 

    In the hope that it works,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by Mykie89 Monday, September 2, 2013 4:08 PM
    • Unmarked as answer by Mykie89 Monday, September 2, 2013 4:08 PM
    Monday, September 2, 2013 7:25 AM
  • I found the solution: I set only the StartTimeZone and works good:

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.Local);
    appointmentItem.Start = Convert.ToDateTime(oListItem["Start"]);
    appointmentItem.StartTimeZone = TimeZoneInfo.Local;

    Thanks Fred!

    Monday, September 2, 2013 4:08 PM
  • I have exactly the same problem with Java, but I can't use TimeZoneInfo.Local ! It doesn't exist. 

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.Local);

    I only have

    new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZone.getDefault())

    But it doesn't work....

    Do you have another solution ?

    Friday, December 6, 2013 9:17 AM