cypht
cypht copied to clipboard
Delete attachments but keep email
Delete attachments but keep emails. Here is the link of the task: https://avan.tech/item60587. I added a delete button that allows you to delete an attached file if it exists on the server.
@NasserNgandu Just to be sure (I didn't test)
- This needs to be optional (default off)
- There should be a confirmation message when deleting an attachment (to avoid accidents)
@marclaporte. There is already a confirmation message, I can just make it optional.
@NasserNgandu : no need to make the confirmation message optional. This is a rare operation, and it makes sense that the user always confirms.
@marclaporte. Alright, I leave it like that.
This is not functionally correct I'm afraid (I like the idea and appreciate the work), however attachments are only stored on the web server when attaching them to outgoing E-mail. Attachments on messages you have in your IMAP account and stored in the IMAP server. To remove an attachment requires the following steps:
- read in the entire message and parse the MIME structure
- identify the portion of the message that represents the attachment to delete
- save a new message with all other parts except the deleted part
- delete the original message
"save a new message with all other parts except the deleted part" -> And not change the date so the sort order remains as before
@marclaporte @jasonmunro. Could you enlighten me on how to save a new message without touching the timestamp. I did a search and couldn't find a way to do this.
@marclaporte @jasonmunro. Could you enlighten me on how to save a new message without touching the timestamp. I did a search and couldn't find a way to do this.
You cannot. E-mail messages have a date header, this you should maintain from the original E-mail. However IMAP servers manage a created timestamp (commonly referred to as "arrival time") and you cannot change that.
I did not look thoroughly at the RFC but it would be great if we could keep at least some header or an "empty space" at the original place.
If that is entirely impossible, then we shall save the original timestamp e.g. as a (potentially hidden) tag with a predefined prefix to be able to search & find & sort the mails according to the original order which for myself is very important.
Half a year ago I was quickly scripting something using curl and IMAP and I remember some hacky things like issuing COPY to a temporary folder to preserve time and other attributes. IDK but maybe this could be somehow combined with sieve filtering during the "COPY" to the special temporary folder.