0 votes
by (300 points)

I'm using Rebex to send an email like this:

        // Get EwsItemId
        ewsItemId = _ewsClient.StoreMessage(EwsFolderId.Drafts, mailMessage);

        _ewsClient.SendMessage(ewsItemId, ewsFolder.Id);

Then I grab the ewsItemId and store it as a string in the database. Something like:

AABSIABVMY4TQZLEGIYC2NRVHFTC2NBZHAYC2OBWMI2C2ZBSHA3WGMDDGFRDMN3GABDAAAAAAAABJY73B6SHOJCOW2N5DEZJ3NTBKBYAFLWTJ5HFCWQERLN2LNK7XUAVCEAAAAAAAEEQAABK5U2PJZIVUBEK3OS3KX55AFIRAAAKVMLXP4AAA===-

Then later I get this Id and do:

        EwsItemId ewsItemId = new EwsItemId(itemId);

        EwsItemInfo item = _ewsClient.GetItemInfo(ewsItemId);

and I get the following exception:

Rebex.Net.EwsException: The specified object was not found in the store., Cannot get ID from name (ErrorItemNotFound).

I know that actually the EwsItemId is composed by an Id and a ChangeKey. Must I also store the ChangeKey? What's the best approach to store the EwsItemId in the database for later use?

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (15.2k points)
selected by
 
Best answer

Hello,

you store the EWS Id correctly. But when you send the stored message, it is moved to another folder and its id is changed, not only its change key. So your id of the stored message is not valid at that point.
Unfortunately, Exchange server do not include new Id of the sent message that is moved/created to your folder with ewsFolder.Id.
Sending the message and using Sent Items folder doesn't help neither. Your only option is to find the sent message in your folder using Ews.Search(...) method to get new id of the sent message and store this in your database for later use.

...