15 May 2011

Remove attachments from Gmail

As far as webmail goes, Gmail is the most advanced feature-wise; sometimes I get the feeling the competition is not even trying to catch up. Even so, there are some useful things you cannot do in the Gmail web interface, that are available in offline email clients. One of those features I found very handy both in Lotus Notes and in Outlook is the ability to remove attachments from messages while keeping the text; the conversations are usually as important as the files. It’s a life saver when you are nearing your storage quota: search the largest messages, save the attachments locally and then delete them from the email server. I prefer this to creating an ‘archive’, because I hate having to search for messages in two different places – the normal inbox and the archive. As long as you have a good system for filing the attachments this should be more efficient.

You might think Gmail doesn’t have the same problem with storage, because there’s so much of it available – more than 7 GB and counting. But an inbox can fill up much quicker than Gmail increases the storage. While Gmail on the web doesn’t support the removal of attachments, there is a workaround by using IMAP to connect Gmail to a local email client:

  • First of all enable IMAP access from the Gmail settings and configure a local client like Mozilla Thunderbird or Microsoft Outlook. Wait until the messages and folder structure are synced to your computer.
  • Locate the messages where you want to remove the attached files in the local client. You can also mark them on the web by labeling or starring them – labels will convert to folders in the IMAP client.
  • Copy these messages in ‘Local folders’ in the mail client and delete the attachments from this local copy of the message. Thunderbird and Outlook behave somewhat differently at this step. Thunderbird leaves behind a “trace” of the original attachment in the message, labeling it “deleted” – this way you can still find the message by using the criterion has:attachment, even if the actual file size is negligible. Outlook on the other hand will remove the files entirely, as if they were never there.
  • Go back to the Gmail web interface and delete the original messages.
  • In the local client copy – or move – the copies, now attachment-free, back to the Gmail folders.

And done! The method is a little tedious, but the results are nearly perfect: the original time stamps are preserved and in my experience, the messages also fit in to the correct conversation threads. Alternatively you could open the messages directly from the Gmail IMAP folders in the local client and perform the delete, but this way the original date is lost, it gets replaced with the date when you removed the attachment.

  • Gmail original message with attachment
    Original message in Gmail with attachment
  • Gmail message with removed attachment
    Message after attachment removal in Thunderbird

Given the importance places on the cloud strategy, it’s a bit odd that users need to rely on desktop software for this operation. For most office formats you can already save them to Google Docs, so replacing the original attachment with a link to the live file on Google Docs seems like the next logical step. But maybe this falls into the category: “not enough people would use the feature to justify the investment”.

17 comments:

  1. I second the motion that Google should add this feature

    ReplyDelete
  2. This general procedure has worked well for me in avoiding Gmail quota overflow while retaining all my messages with original metadata and conversation threads. However, I have found the process can be made easier using the following modifications. (I am posting here since all the relevant Gmail support discussions appear to be closed.)

    Software used:
    * Thunderbird 3.1.10 on Ubuntu 10.10 GNU/Linux x86_64
    * Thunderbird add-on Attachment Extractor 1.3.5 (https://addons.mozilla.org/en-US/thunderbird/addon/attachmentextractor/)

    (1) Assuming one has identified messages containing large attachments to be deleted by using Thunderbird, it is easier to delete the original messages using Thunderbird, rather than deleting them through the Gmail web interface. (This also allows one to delete only the messages with large attachments rather than the entire associated conversations, which I have not found a way to do through the Gmail web interface.) Without any special modifications to the IMAP configuration, this can be accomplished by: (i) moving the original messages from their [Gmail] folders, e.g., [Gmail]/All Mail, to [Gmail]/Trash; (ii) deleting the messages in [Gmail]/Trash; (iii) right-clicking on [Gmail]/Trash and choosing "Empty Trash".

    (2) When deleting the attachments in a local copy of the target messages, it is convenient to automate the process somewhat using the Attachment Extractor add-on for Thunderbird, as described here. This extension uses Thunderbird's capability of "detaching" attachments from messages. In order to maintain an association between messages and attachments, I chose to create two local copies of the target messages, one with attachments preserved, and one with attachments deleted. However, even if you delete the attachments on one copy of the messages, you may need to temporarily allow Attachment Extractor to create local copies on disk, as discussed here. I used the extension with the "Delete with normal Thunderbird code" option; while it became unresponsive and had to be restarted several times over 100+ messages, and failed to delete a few attachments altogether, it proved considerably faster than deleting attachments by hand.

    After copying the messages with attachments deleted back to [Gmail]/All Mail, the messages were re-integrated with the appropriate conversation threads in the Gmail web interface. As none of the attachments I deleted belonged to messages with labels, I did not encounter the issues discussed in the Gmail support forums on this topic. However, it's worth noting that you can avoid including messages with certain labels, stars, etc. by using additional filter rules in Thunderbird besides message size.

    Thanks GXG for pointing me in the right direction!

    ReplyDelete
  3. And thank you for the generous contribution with this long comment!

    I don't use additional extensions for the process because until now I had relatively few messages where to apply the procedure, but you're right, you can go even further to make it more efficient.

    ReplyDelete
  4. so I landed here to find out how to delete old attachments and I still dont have answer after reading this. you wasted 15 seconds of my time dumb ass.

    ReplyDelete
    Replies
    1. And you wasted 15 seconds of my time reading your useless comment. Guess that makes us even.

      Delete
  5. Thank you both very much! Here is my version...

    --I use Thunderbird to keep a local copy of my Gmail account. My All Mail folder is about 4GB, and I have unsubscribed my 750MB Gmail Sent Mail folder to avoid duplicates. [I still have duplicates from some of my other labels, but space is not an issue for them-- and, in the event of a disaster, I do care about those labels for filing purposes.]

    --In order to reduce my local disk space usage, I whack msgs w/ large attachments. But, sometimes, I do want to keep the conversation.

    --I edited Thunderbird's server settings as follows: Gmail >> When I delete a message: Move it to Trash. That gives me a chance to fix an oops.

    --For each msg whose attachments I want to whack, I right-click copy or move (they are the same thing, unfortunately -- it would be nice if move worked w/ Gmail as copy-and-delete) to my local "whack the attachments" folder.

    --I whack the attachments (that's beyond tedious -- I'd love a Delete All Attachments button that works for multiple msgs), and then right-click move them back to Gmail All Mail.

    --Finally, I click the delete button for the original All Mail msgs w/ the attachments. [I sort All Mail by size, so there is no confusion about which msg has the attachment.]

    --I don't worry about the Gmail Trash folder -- Gmail will empty it in 30 days. I have 25GB free for Gmail -- I'm just interested in keeping my local All Mail backup as slim as possible.

    Thanks again for giving me the idea for the local folder attachment surgery!

    BTW, I bought Gmail Organizer to try do this more cleanly. Unfortunately, it's so buggy that it's worthless. Total waste of money for me. Maybe the next version...

    Mike

    ReplyDelete
    Replies
    1. Hi, Mike,

      Thanks for the comment! As I found out from a previous commenter, there is a Thunderbird Extension that can detach/remove attachments from multiple messages at once called AttachmentExtractor.
      I don't remember if I tried it personally, because I usually don't go through this procedure very often and don't have that many attachments to scrub.

      Delete
  6. Great article thanks. I don't want to spend time doing this. I just wish Gmail would enable deletion of attachment without deleting the email message.

    ReplyDelete
  7. Attachment Extractor worked like a charm for me! Thanks for the tip :)

    ReplyDelete
  8. George,

    I have come up with an online alternatively which lets you do this via Google Apps Script. Do check by blog and share your feedback. I don't want to spam here with the link ;)

    ReplyDelete
    Replies
    1. Thanks, it looks like a good solution, I might try it out sometimes. Would it be possible to remove attachments from just a couple of messages from the list instead of all? Or to select messages by label? I don't usually need to remove all attachments above some size, instead I'm going for specific messages.

      Delete
  9. George, any possibility of you making a video tutorial for this? For a beginner, it's hard to follow.

    ReplyDelete
    Replies
    1. I'll try, but I can't promise anything. I don't really have the right tools for a video tutorial now and not enough time to set them up.

      Delete
  10. Very nice trick, thanks for this. Works fantastic. The email stripped of attachments integrates right back into its gmail thread with no issues. I use pine for my mail client, and it puts a message mentioning the name and size of the deleted attachment(s) too.

    ReplyDelete