Retrieve EwsItemId after sending an email

0 votes
asked Mar 2, 2018 by abarref (290 points)

After sending an email:

_ewsClient.SendMessage(mailMessage, ewsFolder.Id);

I would like to retrieve the EwsItemId associated to it so I can store it on our database for later use.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Mar 5, 2018 by stepantalalayev (3,940 points)
selected Mar 6, 2018 by abarref
Best answer


the EwsItemId can be obtained by saving message in drafts by calling ewsClient.StoreMessage that give you item id and then you can send the message giving as parameter the EwsItemId. Here is the code:

// Get EwsItemId
var ItemId = ewsClient.StoreMessage(EwsFolderId.Drafts, message);

// store EwsItemId in database

// Send message