exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Exchange 2007 Web Service, get new emails

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Development
Author Message
Eric



Joined: 05 Aug 2007
Posts: 12

PostPosted: Mon Jan 28, 2008 5:55 pm    Post subject: Exchange 2007 Web Service, get new emails Reply with quote

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;

Archived from group: microsoft>public>exchange>development
Back to top
View user's profile Send private message
Henning Krause [MVP - Exc



Joined: 05 Aug 2007
Posts: 142

PostPosted: Tue Jan 29, 2008 2:20 am    Post subject: Re: Exchange 2007 Web Service, get new emails Reply with quote

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 @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;
>
>
>
>
>
>
Back to top
View user's profile Send private message
Eric



Joined: 05 Aug 2007
Posts: 12

PostPosted: Fri Feb 01, 2008 3:52 pm    Post subject: Re: Exchange 2007 Web Service, get new emails Reply with quote

Thanks!

"Henning Krause [MVP - Exchange]"
wrote in message @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
> @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;
>>
>>
>>
>>
>>
>>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Exchange 2007 - Getting mailbox size from enterprise service I am attempting to retrieve the mailbox size for a specified account using PowerShell from a .NET enterprise service (running as a domain admin). The same code works fine from a console application, but I always get an error like "The specified mailbox da

Exchange 2007 Web Service + Event Sink Integration I have a requirement to synchronise our contact data between an Exchange Public Contacts Folder and our application's database. We are using Exchange 2007 SP1 connecting to Outlook 2007 clients. Creating contacts in the Exchange Public Folder works great

Use Mapi in web service Hi. I develop an ASP.NET web service that calls COM Interop function which do some work by MAPI (change properties of some mails in a given users mailbox) .. The problem is when I put my web service under IIS the exception is thrown from Mapi it can't cr

processing emails in bv6 Hello All: I need to write an vb6 application to go thru emails in an inbox on Exchange 2003 and send emails out based on information on the original incoming email. The application needs to run and process emails every hour or so, or better yet respond t

Exchange 2007 SP1 SDK Hi all, I installed a few days ago Exchange 2007 SP1 SDK on 64-bit machine with 64-bit Exchange 2007 installed. I wanted to learn how transport agents for Exchange 2007 work. So I built, installed and started an SDK sample named However,
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group