|
|
|
date: Mon, 28 Jan 2008 12:55:56 -0500,
group: microsoft.public.exchange.development
back
Re: Exchange 2007 Web Service, get new emails
Hello,
FindItem will never return all properties.
You'll have to perform a FindItem first and then a GetItem on the details
you want to retrieve.
Kind regards,
Henning Krause
"Eric" wrote in message
news:eswvJcdYIHA.5980@TK2MSFTNGP04.phx.gbl...
>I started with the Exchange 2007 code samples from MSDN, for retrieving
>messages from Exchange via web services.
> Even though I specify "itemProperties.BaseShape =
> DefaultShapeNamesType.AllProperties;" many of the fields in each message
> (email addresses, body, etc.) are null.
> I am trying to use "itemProperties.AdditionalProperties" to include the
> message Body, but it is causing an error.
>
> Where do I go from here?
>
> Thanks,
>
> Eric
>
> ExchangeServiceBinding NewESB = CreateESB();
>
> FindItemType findItemRequest = new FindItemType();
>
> findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
>
> ItemResponseShapeType itemProperties = new ItemResponseShapeType();
>
> //*******Even though I specify AllProperties, not all of the properties
> are
>
> itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
>
> itemProperties.BodyType = BodyTypeResponseType.Text;
>
> PathToUnindexedFieldType TheBody = new PathToUnindexedFieldType();
>
> //***********THIS FOLLOWING LINE IS CAUSING THE PROBLEM?
>
> TheBody.FieldURI = UnindexedFieldURIType.itemBody;
>
> //***********ErrorMessage from EWS is "Property is not valid for this
> operation" for the Element "t:FieldURI"
>
> itemProperties.AdditionalProperties = new BasePathToElementType[1];
>
> itemProperties.AdditionalProperties[0] = TheBody;
>
>
> findItemRequest.ItemShape = itemProperties;
>
> DistinguishedFolderIdType[] TypeArray = new DistinguishedFolderIdType[1];
>
> TypeArray[0] = new DistinguishedFolderIdType();
>
> TypeArray[0].Id = DistinguishedFolderIdNameType.inbox;
>
> findItemRequest.ParentFolderIds = TypeArray;
>
> FindItemResponseType findItemResponse = NewESB.FindItem(findItemRequest);
>
> ArrayOfResponseMessagesType responses = findItemResponse.ResponseMessages;
>
>
>
>
>
>
date: Mon, 28 Jan 2008 21:20:12 +0100
author: Henning Krause [MVP - Exchange]
Re: Exchange 2007 Web Service, get new emails
Thanks!
"Henning Krause [MVP - Exchange]"
wrote in message news:OfmLzseYIHA.5180@TK2MSFTNGP06.phx.gbl...
> Hello,
>
> FindItem will never return all properties.
>
> You'll have to perform a FindItem first and then a GetItem on the details
> you want to retrieve.
>
> Kind regards,
> Henning Krause
>
> "Eric" wrote in message
> news:eswvJcdYIHA.5980@TK2MSFTNGP04.phx.gbl...
>>I started with the Exchange 2007 code samples from MSDN, for retrieving
>>messages from Exchange via web services.
>> Even though I specify "itemProperties.BaseShape =
>> DefaultShapeNamesType.AllProperties;" many of the fields in each message
>> (email addresses, body, etc.) are null.
>> I am trying to use "itemProperties.AdditionalProperties" to include the
>> message Body, but it is causing an error.
>>
>> Where do I go from here?
>>
>> Thanks,
>>
>> Eric
>>
>> ExchangeServiceBinding NewESB = CreateESB();
>>
>> FindItemType findItemRequest = new FindItemType();
>>
>> findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
>>
>> ItemResponseShapeType itemProperties = new ItemResponseShapeType();
>>
>> //*******Even though I specify AllProperties, not all of the properties
>> are
>>
>> itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
>>
>> itemProperties.BodyType = BodyTypeResponseType.Text;
>>
>> PathToUnindexedFieldType TheBody = new PathToUnindexedFieldType();
>>
>> //***********THIS FOLLOWING LINE IS CAUSING THE PROBLEM?
>>
>> TheBody.FieldURI = UnindexedFieldURIType.itemBody;
>>
>> //***********ErrorMessage from EWS is "Property is not valid for this
>> operation" for the Element "t:FieldURI"
>>
>> itemProperties.AdditionalProperties = new BasePathToElementType[1];
>>
>> itemProperties.AdditionalProperties[0] = TheBody;
>>
>>
>> findItemRequest.ItemShape = itemProperties;
>>
>> DistinguishedFolderIdType[] TypeArray = new DistinguishedFolderIdType[1];
>>
>> TypeArray[0] = new DistinguishedFolderIdType();
>>
>> TypeArray[0].Id = DistinguishedFolderIdNameType.inbox;
>>
>> findItemRequest.ParentFolderIds = TypeArray;
>>
>> FindItemResponseType findItemResponse = NewESB.FindItem(findItemRequest);
>>
>> ArrayOfResponseMessagesType responses =
>> findItemResponse.ResponseMessages;
>>
>>
>>
>>
>>
>>
>
date: Fri, 1 Feb 2008 10:52:04 -0500
author: Eric
|
|