Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending a reply email using exchange web services - how to deal with the changeKey property

For my code, I retrieve an unread message from exchange, do some processing based on that message, and then reply to the message with the results of the processing I did.

The problem that I'm having is that when I attempt to reply to the email I'm getting the below error on calling responseMessage.send() or responseMessage.sendAndSave():

The current ChangeKey is required for this operation.

Below is the code that I am running that is triggering this error:

public void replyToEmail(EmailMessage _emailMessage, String _reply)
    {

        String serviceManager = emailServerAddress = ConfigurationSettings.AppSettings["serviceManagerEmail"].Trim();
        ResponseMessage responseMessage = _emailMessage.CreateReply(true);
        responseMessage.BodyPrefix = _reply;

        String changekey = _emailMessage.Id.ChangeKey;

        if (!serviceManager.Equals(""))
        {
            responseMessage.CcRecipients.Add(new EmailAddress(serviceManager));
        }

        responseMessage.Send();
    }

I'm able to check the _emailMessage changeKey value via _emailMessage.id.Changekey and there is a value there, I would have expected that to be assigned to the responseMessage when _emailMessage.createReply() was call. I'm unable to find a way to manually assign it.

I've been unable to find any references to this issue during searching, I was hoping someone

like image 748
Christopher Gerdes Avatar asked Nov 01 '12 19:11

Christopher Gerdes


1 Answers

I ran into this problem with .Forward, after setting the message IsRead = true and saving that update back to the server. That changes the ChangeKey, so it's no longer valid.

Try doing _emailMessage.Load() to get the message from the server again, and the new ChangeKey.

like image 77
Tridus Avatar answered Oct 24 '22 04:10

Tridus