Gmail attachment remover
This is an app that connects to your Gmail account via imap and removes selected large attachments, without screwing up conversations/threads/labels.
- Before removing an attachment, a local full backup of the raw email is saved. But you should save your important attachments manually before!
- The removed attachment is replaced by a text-file attachment containing the original attachment filename and size.
Do this in Gmail:
- Enable imap access in Gmail's settings, best enable access to all folders.
- Optional: assign a label (e.g.,
removeattachments) to emails where large attachment(s) should be removed (e.g. via filter on size in gmail). Mind that Sgar can't remove this label if you use the
conversation viewin Gmail, because all emails in a conversation get the same label.
On your computer:
- Get the Java JRE >= 8u101. Don't forget to untick the crapware installer, and/or disable it permanently!
- Download a zip for Mac or (Windows, Linux), extract it somewhere and double-click the app (Mac) or jar file (Windows, Linux).
- Gmail account (email): You can deal with multiple accounts with different settings.
- Password: I suggest to use "application specific passwords" just click the button and get a password for "Mail".
- Select a folder for mail backups.
limit: select a maximum number of emails processed, e.g., 100. After this you can check the emails if everything is fine, further the process might take very long and google might interrupt the connection from time to time.
label: Gmail message label to be searched for, e.g.
removeattachments. It is removed after attachment removal (doesn't work in conversation view, see above). If empty, this is ignored.
gmail search: use a "RAW Gmail search term" to pre-filter emails. See the examples in the drop-down list and here for information.
size:1MB has:attachment older_than:12m -in:inboxis a good choice: mails that are small, in the inbox, within the last 12 month, or without attachment, are skipped.
minimum Attachment size: Select a minimum size above which attachments will be considered. Important for multiple attachments in mails!
Find emails. The table will contain emails matching the criteria.
- Check the table and remove rows from the table if they should not be processed.
Remove attachmentsto start the removal procedure.
- This might take very long because the full messages are downloaded for backup, and Gmail limits bandwidth (~500 kB/s)!
Is it safe to use?
- The Gmail trash folder is emptied in the process.
- The password is saved in clear text in the settings file.
- It works very well here since >5 years, but Google might change something at any time which could break it.
- If the software or connection is interrupted:
- In the worst case you have lost the labels of one email, more likely is to have an additional email, but in most cases nothing happens, just start over.
- You always have a downloaded backup of the email.
- Probably, you should always have a backup your Gmail account with, e.g., gmvault; however, mind that this is not incremental.
- Of course I cannot take any responsibility for anything.
How to develop, compile & package
- Get Java JDK >= 8u101
- check out the code (
hg clone ...or download a zip)
- I use the free community version of IntelliJ IDEA with the scala plugin for development, just open the project to get started.
Run the program from terminal and package it:
- Install the Scala Build Tool
- Compile and run manually:
- Package for all platforms:
sbt dist. The resulting files are in
Suggestions, bug reports, pull requests
Please use the provided tools for bug reports and contributed code. Anything is welcome!
- scalafx as wrapper for javafx
- sbt-javafx for packaging
- javamail for everything about IMAP and Gmail
- Only attachments which have a "filename" are considered. This excludes effectively html/text message parts.
- IMAP message flags are preserved.
- Gmail message labels are preserved. If the
labeltag (see above) exists, it is removed after attachment removal (doesn't work for conversation view).
- The processed mails get a new message-ID, which doesn't matter.
- On mac, the computer doesn't sleep during "Find emails" and "Remove attachments"
- License: GPL