Subject: [Jmap] Another question about updating a draft Email

From: Mildred Ki'Lya <[email-masked]>
Date: Wed, 10 Nov 2021 23:09:19 +0100

Hello,

For the lack of a better mailing list, I believe I took this place as a 
support forum :) I need to take an existing draft Email, modify it 
(through the compose interface I'm building) and then save it back with 
the changes. I would like the changed Email to be as close as the 
original as possible (same headers, ...). For this reason I'm taking the 
result of an Email/get operation, patch it with the changed values, and 
feed it to Email/set (create). If I could I'd try to update the Email 
object but i understand that's not possible as Email are immutable.

Doing so, I uncovered a bug in the previous version of Cyrus 
<https://github.com/cyrusimap/cyrus-imapd/issues/3766> most probably 
related to the additional extra fields I'm including in Email/set. 
Properties such as id, threadId, blobId, size, trustedSender, 
hasAttachment, preview, and similar properties in textBody and htmlBody 
are rejected by the server (rightfully as this is not part of the Email 
file itself).

Again, am I missing something on how to do this easily without having to 
prune those illegal properties before calling Email/set. Is there a way 
to update an Email object. I'm also asking this because some received 
Emails contains bogus information (such as bogus dates) that might be 
interesting to correct while keeping all the other headers (including 
the Received headers).

Thank you

Mildred

---

From: "Neil Jenkins" <[email-masked]>
Date: Tue, 16 Nov 2021 13:35:07 +1100

If you fetch the `headers` property you'll get a list of all headers in the email (unparsed). You should be able to use that in the `Email/set` to get the create a message with the sam set of headers (or you could modify some first). Similarly the `bodyStructure` property to clone the existing body structure. Then it's just a matter of including the metadata properties to put it in the mailbox(es) you want/set any keywords.

—Neil