IMAP - editing a draft or existing message?
Asked Answered
H

2

9

For those of you familiar with IMAP - If I retrieve a draft message (or any message for that matter), and I wish to update it / edit it, what commands should I use?

The only command i've come across is Append, which appears to only insert, meaning I would have to delete the previous draft from the mailbox?

Heritage answered 5/6, 2013 at 16:22 Comment(0)
K
16

IMAP is designed for server-side management of mailboxes, not for editing messages. So yes, you would have to retrieve the contents of the desired message (FETCH), then delete that message from the server (STORE a \Deleted flag on the message and then EXPUNGE deleted messages), and then upload the updated message to the server (APPEND). There are no IMAP commands for editing the contents of an existing message, only for updating flags related to existing messages (STORE).

Kristin answered 5/6, 2013 at 16:27 Comment(4)
Indeed, the specification guarantees that a specific message object (identified with a UID) is immutable. That's an important guarantee for caching email clients. Being able to edit a message would break that guarantee.Vector
I just want to add that by RFC3501 UIDs are immutable only within session tools.ietf.org/html/rfc3501#page-8Radiosurgery
It can be desirable to edit an IMAP message. With the proliferation of the ZenDesk email support system, thread/convo view in gmail + all clients break easily. Gmail appears to use a combo of subject, to, from, and date range. I prefer using the in reply-to-ID and message-ID's. Altering subjects to get the thread/convo view back would be great. Also adding my original email to the thread/convo instead of searching a support ID#. Anyone aware of an IMAP client that does simple editing of subjects + removal of attachments where the email is marked where the files were saved to?Rightward
Note that the answer's reference to DELETE is not exactly accurate. IMAP's DELETE is for folders (or "mailboxes", as the spec calls them). Deleting messages is done via a combination of STORE and EXPUNGE.Bourassa
P
6

Remy's answer is correct. On top of that, you could optimize the process a bit if the server supports the CATENATE extension via APPEND CATENATE (so that you could save yourself uploading the existing attachments, etc).

Penicillium answered 6/6, 2013 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.