1

I am trying to give the users additional information about emails they received in form of an email in the same conversation.

What I do

from exchangelib import Message

# Works:
account = Account(primary_smtp_address=smtp_address, config=config,
                  autodiscover=False, access_type=DELEGATE)
mail = A message received under account

# Works, but probably needs adjustment:
m = Message(account=account,
            subject=mail.subject,
            conversation_id=mail.conversation_id,
            body='Test',
            to_recipients=[account.primary_smtp_address])

# Throws error below
m.send()

I get

Traceback (most recent call last):
  File "myscript.py", line 114, in myfunction
    m.send()
  File "/usr/local/lib/python2.7/dist-packages/exchangelib/items.py", line 507, in send
    res = self._create(message_disposition=SEND_ONLY, send_meeting_invitations=send_meeting_invitations)
  File "/usr/local/lib/python2.7/dist-packages/exchangelib/items.py", line 176, in _create
    send_meeting_invitations=send_meeting_invitations)
  File "/usr/local/lib/python2.7/dist-packages/exchangelib/account.py", line 260, in bulk_create
    send_meeting_invitations=send_meeting_invitations,
  File "/usr/local/lib/python2.7/dist-packages/exchangelib/account.py", line 254, in <genexpr>
    i if isinstance(i, Exception)
  File "/usr/local/lib/python2.7/dist-packages/exchangelib/services.py", line 451, in _pool_requests
    elems = r.get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 567, in get
    raise self._value
ValueError: 'changekey' is a required field with no default

What is the problem and how do I fix it?

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • The problem is that I set `conversation_id` – Martin Thoma Aug 11 '17 at 08:51
  • `conversation_id` is a read-only field in exchangelib, so the above is not going to work anyway. I'm not sure if you can even specify a conversation ID manually via EWS. – Erik Cederstrand Aug 14 '17 at 12:05
  • @ErikCederstrand What does it mean that it is a read-only field? The above produced exactly the result as stated. Without the "send" it does not seem to be read-only. – Martin Thoma Aug 14 '17 at 12:13
  • @ErikCederstrand I think it is desirable to be able to set it. In my case, I want to automatically add a message to a conversation. I don't think there is a reliable way to do so without setting the `conversation_id`. Only setting the subject line does not always work. – Martin Thoma Aug 14 '17 at 12:37
  • @ErikCederstrand Or setting `In-Reply-To` would probably also work. I'm not sure how to do so with `exchangelib` – Martin Thoma Aug 14 '17 at 12:43
  • `Original-message-id` might be interesting, too - https://tools.ietf.org/html/rfc4021#page-20 – Martin Thoma Aug 14 '17 at 12:49
  • Or the [`References`](https://tools.ietf.org/html/rfc4021#page-11) field. – Martin Thoma Aug 14 '17 at 12:51
  • 1
    "read-only" in this context means that you can set the attribute to whatever you want (because this is Python) but that exchangelib will ignore the value when sending updates to the Exchange server. It's possible that the field *is* in fact modifiable via EWS, I just haven't tested it to work. – Erik Cederstrand Aug 14 '17 at 13:22

1 Answers1

0

The problem is that I set conversation_id. It is actually not necessary to set the conversation ID if I only want the message to be shown in the same conversation. Only setting the subject line exactly the same seems to be enough.

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958