I’m struggling with moving email to newly created folder. (I’m using Exchange 2007) Please advise.
I was using this url as guidance:
I created folder on the root called “Testing”
Here is my code snippet:
NetworkCredential credentials = new NetworkCredential(Properties.Settings.Default.Exchange_Username, Properties.Settings.Default.Exchange_Password);
EWSClient client = EWSClient.GetEWSClient(Properties.Settings.Default.Exchange_EWS_Url,
credentials)
ExchangeQueryBuilder builder = new ExchangeQueryBuilder();
builder.Subject.Equals(“Test”);
builder.InternalDate.BeforeOrEqual(DateTime.Now);
MailQuery query = builder.GetQuery();
ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri, query);
foreach (ExchangeMessageInfo msgInfo in msgCollection)
{
client.MoveItem(msgInfo.UniqueUri, client.MailboxInfo.RootUri + “/Testing/” + msgInfo.Subject);
}
I get this error:
Item move failed. System.InvaidOperationException: Item move failed.
I even tried this:
client.MoveItem(msgInfo.UniqueUri, client.MailboxInfo.RootUri + “/Testing/”)
However I was able to successfully move to a predefined folder:
client.MoveItem(msgInfo.UniqueUri, client.MailboxInfo.DeletedItemsUri);