Error when I try to read/update the .Body of a Task via EWS Managed API - “You must load or assign this property before you can read its value.”

后端 未结 3 1148
无人及你
无人及你 2020-12-14 14:39

I am using the Exchange Web Services Managed API to work with Tasks (Exchange 2007 SP1). I can create them fine. However, when I try to do updates, it works for all of the

相关标签:
3条回答
  • 2020-12-14 15:16

    You can load properties using a custom property set. Some properties are Extended properties instead of FirstClassProperties.

    Little example:

            _customPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.MyResponseType, AppointmentSchema.IsMeeting, AppointmentSchema.ICalUid);
            _customPropertySet.RequestedBodyType = BodyType.Text;
            appointment.Load(_customPropertySet);
    
    0 讨论(0)
  • 2020-12-14 15:18

    Calling the Load method solved my problem :)

    foreach (Item item in findResults.Items)
            {                
                item.Load();
                string subject = item.Subject;
                string mailMessage = item.Body;
            }
    
    0 讨论(0)
  • 2020-12-14 15:28

    I had the same problem when using the EWS. My Code is requesting the events(Appointments) from the

    Outlook calendar, at the end I couldn't reach to the body of the Event itself.

    The missing point in my situation was the following "forgive me if there is any typo errors":

    After gathering the Appointments, which are also derived from EWS Item Class, I did the following:

    1- Create a List with the type Item:

    List<Item> items = new List<Item>();
    

    2- Added all appointments to items list:

    if(oAppointmentList.Items.Count > 0) // Prevent the exception
    {
        foreach( Appointment app in oAppointmentList)
        {
            items.Add(app);
        }
    }
    

    3- Used the exchanged service "I have already created and used":

    oExchangeService.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);
    

    now if you try to use app.Body.Text, it will return it successfully.

    Enjoy Coding and Best Luck

    I forgot to mention the resource:

    http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/ce1e0527-e2db-490d-817e-83f586fb1b44

    He mentioned the use of Linq to save the intermediate step, it will help you avoid using the List items and save some memory!

    RockmanX

    0 讨论(0)
提交回复
热议问题