Removing attachments.

496 views
Skip to first unread message

Jacek Generowicz

unread,
Jun 22, 2012, 4:46:05 AM6/22/12
to Mu Discuss
Hi,

I'm trying to address the problem which is described pretty well here:

,----[ http://email.about.com/od/mozillathunderbirdtips/qt/et052806.htm ]
|
| As useful as attachments are, their purpose is often fulfilled when the
| file has been saved or edited or simply seen. If you want to save the
| message for reference, the dilemma is not easily resolved: keep the
| message and clog a folder with dozens of MB of unneeded data or purge
| the email together with the files attached to it.
`----

Can anyone suggest how to address this problem with offlineimap-based
setups?

Would it be possible to add a higher-level mechanism for dealing with
this problem in mu4e?

Specifically, I want to be able to remove attachments from some mail
message while keeping the rest of the message in my Maildir, *and* have
the change (removal of attachment) propagate to my IMAP server.

Any thoughts?

Thanks.

Stephen Eglen

unread,
Jun 23, 2012, 1:35:30 AM6/23/12
to mu-di...@googlegroups.com
I asked about this a while ago too, as I have the same problem.  I found a python tool to help delete attachments from a message, but have yet to integrate it with mu4e.  An extra issue is that offlineimap won't guarantee to work if you edit the message, so the approach will be to write a new edited message and delete the old one.

Stephen

Jacek Generowicz

unread,
Jun 23, 2012, 1:59:09 AM6/23/12
to Mu Discuss

[JG = Jacek Generowicz <jacek.ge...@googlemail.com>]

JG> [...]
JG>
JG> ,----[ http://email.about.com/od/mozillathunderbirdtips/qt/et052806.htm ]
JG> |
JG> | As useful as attachments are, their purpose is often fulfilled
JG> | when the file has been saved or edited or simply seen. If you want
JG> | to save the message for reference, the dilemma is not easily
JG> | resolved: keep the message and clog a folder with dozens of MB of
JG> | unneeded data or purge the email together with the files attached
JG> | to it.
JG> `----
JG>
JG> Can anyone suggest how to address this problem with
JG> offlineimap-based setups?
JG>
JG> Would it be possible to add a higher-level mechanism for dealing
JG> with this problem in mu4e?
JG>
JG> Specifically, I want to be able to remove attachments from some mail
JG> message while keeping the rest of the message in my Maildir, *and*
JG> have the change (removal of attachment) propagate to my IMAP server.
JG>
JG> [...]

[SE = Stephen Eglen <stephe...@gmail.com>]

SE> I asked about this a while ago too, as I have the same problem. I
SE> found a python tool to help delete attachments from a message, but
SE> have yet to integrate it with mu4e. An extra issue is that
SE> offlineimap won't guarantee to work if you edit the message, so the
SE> approach will be to write a new edited message and delete the old
SE> one. [...]

As long as the dates within the message, and the message's position
within a thread are maintained, I don't see how this would be a problem,
or am I overlooking something?

Dirk-Jan C. Binnema

unread,
Jun 23, 2012, 3:37:54 AM6/23/12
to mu-di...@googlegroups.com
Hi,
For you first requirement, something like this might work (it uses a
tool called 'altermime'):

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun remove-attachment (msg num)
"Remove attachment."
(let* ((attach (mu4e~view-get-attach msg num))
(path (mu4e-msg-field msg :path))
(filename (and attach (plist-get attach :name)))
(cmd (format "altermime --input='%s' --remove='%s'"
path filename)))
(when (and filename
(yes-or-no-p
(format "Are you sure you want to remove '%s'?" filename)))
(shell-command cmd))))

(add-to-list 'mu4e-view-attachment-actions
'("remove-attachment" . remove-attachment))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Note, this works directly on the message itself, no temp messages
involved. I'm not sure what an imap-server would do with such an updated
message, but one way might be to do this on a copy and delete the
original (as Stephen suggests).

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C
Reply all
Reply to author
Forward
0 new messages