We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to perform ItemId conversion for ews?

How do I convert between an Aspose ExchangeMessageInfo.MessageId and a Microsoft.Exchange.WebServices.Data.ItemId

internal void go()
{
ExchangeMessageInfoCollection messages = this.getInboxMessages();
foreach (ExchangeMessageInfo message in messages)
{
MapiRecipientCollection recipients = getMessageRecipients(message);
foreach (MapiRecipient recipient in recipients)
{
string recipientEmailAddress = getRecipientSmtpAddress(recipient);
log(recipientEmailAddress);
}
List itemids = new List();
itemids.Add(new ItemId(message.MessageId));
ServiceResponseCollection response = client_ms.MoveItems(itemids, getFolderIdEnsured("#Errors"));
}
}

as you can see I’m trying to use Microsoft.Exchange.WebServices to move a mail item to a subfolder.

I know that the subfolder id is the correct format for the microst client.

When I try to use MessageId property for an Aspose ExchangeMessageInfo as the itemId for Microsoft’s move operation, EWS responds with: Error, the item id is malformed!

I did manage to get the Microsoft client to convert an ID for me, but I tried all of the output formats and none of them work.

Seemingly the only working input format for the conversion is EntryId

All output formats (except EwsId) respond with “id is malformed”, using EwsId returns “The specified object was not found in the store.” when plugged into MoveItems

List itemids = new List();
AlternateIdBase id = client_ms.ConvertId(new AlternateId(IdFormat.EntryId, message.UniqueUri, smtpAddr), IdFormat.EwsId);

ItemId id2 = new ItemId(((AlternateId)id).UniqueId);
itemids.Add(id2);
ServiceResponseCollection response = client_ms.MoveItems(itemids, getFolderIdEnsured("#Errors"));

SOLVED!

Input Format: EwsLegacyId
Output Format: EwsId

AlternateIdBase id = client_ms.ConvertId(new AlternateId(IdFormat.EwsLegacyId, message.UniqueUri, smtpAddr), IdFormat.EwsId);


How long will this conversion operation work? Will Aspose network for .NET change so that this conversion wont work anymore?