none
How to get calendar body text through exchange web service 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 7:38 AM

Answers

All replies