none
Exchange web service --- How to get calendar body text RRS feed

  • Question

  • Hi, all. I'm using exchange 2007. I had created a calendar which contains some text description in body. But when I use web service to fetch the calendar item object, I find the body member is null. After I serialize the calendar item object, I cannot find the text body either.

    But if I use http request, all works fine. (The body content is in <e:textdescription> label in the returned xml response). But it cannot work using web service request.

    Here is my code:

    // Create the request for all Calendar items between the specified dates
       FindItemType findItemRequest = new FindItemType();
    // Bring back ALL properties on the items returned
       ItemResponseShapeType itemProperties = new ItemResponseShapeType();
       itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
    findItemRequest.ItemShape = itemProperties;
    
    // We want items from the Calendar "Folder"
       DistinguishedFolderIdType[] folderIDs = { new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.calendar } };
       findItemRequest.ParentFolderIds = folderIDs;
    
    findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
    
    // Send request, receive response
       FindItemResponseType findItemResponse = _ExchangeBinding.FindItem(findItemRequest);
    
    // Pull the message from the response
       ArrayOfResponseMessagesType responseMessages = findItemResponse.ResponseMessages;
    ResponseMessageType responseMessage = responseMessages.Items[0];
    
    if (responseMessage is FindItemResponseMessageType)
       {
        FindItemResponseMessageType msgType = (responseMessage as FindItemResponseMessageType);
        FindItemParentType parentType = msgType.RootFolder;
    
        object obj = parentType.Item;
        if (obj is ArrayOfRealItemsType)
        {
         ArrayOfRealItemsType items = (obj as ArrayOfRealItemsType);
    
         if (File.Exists(@"D:\Temp\NewResult.txt"))
         {
          File.Delete(@"D:\Temp\NewResult.txt");
         }
         XmlSerializer x = new XmlSerializer(typeof(CalendarItemType));
    
         StreamWriter writer = new StreamWriter(@"D:\Temp\NewResult.txt",
          true, Encoding.UTF8);
    
         foreach (ItemType item in items.Items)
         {
          CalendarItemType calItem = item as CalendarItemType;
    
          MemoryStream stream = new MemoryStream();
          XmlTextWriter xWriter = new XmlTextWriter(stream, Encoding.UTF8);
          x.Serialize(xWriter, calItem);
          stream = (MemoryStream)xWriter.BaseStream;
          string xmlText = Encoding.UTF8.GetString(stream.ToArray());
          writer.WriteLine(xmlText);
    
         }
    
         writer.Close();
        }
       }
    
    After I get the CalendarItemType, I found the body member is null, so I cannot get the body text which I input into the calendar. Any one can tell me how to get it? Thanks a lot.
    Thursday, January 6, 2011 8:20 AM

Answers

  • Hello Alix Dong,

    The Body property is not returned for any item in a FindItem operation call. You are performing a FindItem call with the ExchangeServiceBinding.FindItem() method. You will need to use the GetItem operation. See the ResponseShapes topic for more information about which properties are returned by the FindItem versus GetItem operations. Please note the distinction that the FindItem operation is essentially a search operation and the GetItem operation is a fetch operation.

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Thursday, January 6, 2011 9:46 PM
    Moderator

All replies

  • If you think it is textdescription, but htmldescription is empty, you could try getting the value for property tag 0x1000 instead.  Not sure how you do that in the Managed API, though.
    Outlook Web Access For PDA , OWA For WAP
    www.owa-pda.com
    email a@t leederbyshire d.0.t c.0.m
    Thursday, January 6, 2011 2:21 PM
  • Hello Alix Dong,

    The Body property is not returned for any item in a FindItem operation call. You are performing a FindItem call with the ExchangeServiceBinding.FindItem() method. You will need to use the GetItem operation. See the ResponseShapes topic for more information about which properties are returned by the FindItem versus GetItem operations. Please note the distinction that the FindItem operation is essentially a search operation and the GetItem operation is a fetch operation.

    With regards,


    Michael | Microsoft Exchange SDK

    The Exchange Development Forum Guide has useful information for using the Exchange Development Forum.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Thursday, January 6, 2011 9:46 PM
    Moderator