Is there anyway to add ExtendedPropertyDefinition, during move operation from one folder to another folder.

Environment:  -

Exchange Server: - Exchange Server 2010 SP3

EWS API: - 2.0

IDE: - Visual Studio 2008

Language: - C#

.

Requirement: -

I am trying to add ExtendedPropertyDefinition during move operation of item. Till now, it is not working. Following snippet, I have used

  // Get the GUID for the property set.
                Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");

 // Create a definition for the extended property.
                ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "EWSProcessStatus", MapiPropertyType.String);

 // Add the extended property to an e-mail message object named "message".
                message.SetExtendedProperty(extendedPropertyDefinition, 1);
I am reading mails from inbox folder; perform some operation and moving to SUCCESS folder(user defined). Before moving, I want to set some property to mail.

.

Kindly assist, I will be really thankful.

August 31st, 2015 8:02am

You can't add anything as part of the MoveOperation as the Move Operations just tells the server you want to move Item X from a to b. What you need to do is either make the addition pre or post move eg in you example that would mean calling the Update Method on message before you call Move.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 12:05am

Mails are coming from different channels and are not having any extended  property set. We are moving mails from Inbox folder to another folder.

You are saying to update property of mail before moving. How can I call Update Method on message. 

" calling the Update Method on message before you call Move."

Kindly suggest.

September 1st, 2015 1:09am

You can't add anything as part of the MoveOperation as the Move Operations just tells the server you want to move Item X from a to b. What you need to do is either make the addition pre or post move eg in you example that would mean calling the Update Method on message before you call Move.

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 4:03am

see https://msdn.microsoft.com/en-us/library/office/dn535506(v=exchg.150).aspx#bk_updateewsma 

in your sample it would just be adding one line

  // Get the GUID for the property set.
                Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}");

 // Create a definition for the extended property.
                ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "EWSProcessStatus", MapiPropertyType.String);

 // Add the extended property to an e-mail message object named "message".
                message.SetExtendedProperty(extendedPropertyDefinition, 1);
                message.Update(ConflictResolutionMode.AlwaysOverwrite);
cheers
Glen

September 1st, 2015 11:07pm

We need to apply Update line two times, before move and and after move. I have checked following line

message.Update(ConflictResolutionMode.AlwaysOverwrite);

It is working fine, thanks for it. But how can I update after move operation.

Let me specify requirement, it is required for securing program operation. We want to set EWSProcessStatus as 0 before move operation, and if move will be successfully, then only we will update extended property value to 1.

 It is because, if any how system crash or operation exit after move line (Not on move operation). Then, Item has already Move into some folder with EWSProcessStatus = 0, i.e. because item has already move, so user will assume transaction has completed, while it is not.

So, for handling this situation; I want to update EWSProcessStatus = 1, if it has moved successfully.

After that on starting of program, I will check those mail in moved folder, whose EWSProcessStatus = 0, so, I will move those mails into inbox (Rollback operation)


Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 11:52pm

If your copying messages between folders in the same Mailbox then you should be able to use the overload for returnNewItemIds in the MoveItems method of the ExchangeService class https://msdn.microsoft.com/en-us/library/gg248139(v=exchg.80).aspx and process the response (if your copying across Mailboxes then you need search for the Item you moved instead).

Cheers
Glen

September 2nd, 2015 1:09am

Thanks, It will be in same mail box.

How can I better implement, following method in my code. Kindly assist, I will be really thankful.

public ServiceResponseCollection<MoveCopyItemResponse> MoveItems(
	IEnumerable<ItemId> itemIds,
	FolderId destinationFolderId,
	bool returnNewItemIds
)

Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2015 1:37am

I don't have an example I would suggest you first try to implement it yourself and post the code your trying to use if it doesn't work somebody can help you fix it.

Cheers
Glen

September 2nd, 2015 7:01pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics