MacOS – How to delete attachments from mails I sent

attachmentsemailmacosmail.app

In Mountain Lion’s Mail app, I can delete attachments from mails others have sent me, but not from the mails I sent to others.

In the mailbox, the messages I have sent are not marked with the small paperclip, even when then have a attachments (however, their size is correct and includes the big attachments). When I select an individual message (or many), the "Delete attachements" menu item is grayed out.

How can I deleted attachments from mails I sent?

Best Answer

Based on the page http://lifehacker.com/5841097/how-to-delete-or-archive-attachments-in-apple-mail-and-free-up-disk-space I used the steps bellow.

** Method recommended only for those who feel comfortable using the Terminal **

  • open the terminal app (Applications > Utilities > Terminal)
  • change to the directory/folder with the emails typing in the terminal window

    $ cd ~/Library/Mail/V2
    
  • list the folders you have

    $ ls
    

    or

    $ ls -1
    
  • you will obtain something like:

    $ ls -1
    IMAP-info@furia.com.br@pop.furia.com.br
    IMAP-infofuria@imap.gmail.com
    MailData
    Mailboxes
    
  • go to the folder of the account you want to clean, list the files and the result shows one or more mbox

    $ cd IMAP-info@furia.com.br@pop.furia.com.br
    $ ls -1
    INBOX.mbox
    

    or

    $ ls -1
    INBOX.mbox
    INBOX0.mbox
    INBOX1014.mbox
    
  • if you have only one mbox, go to this folder, list it and you will see

    $ cd INBOX.mbox
    $ ls
    CE7AE9-C83C-410A-9406-4DEFB7034
    Archive.mbox
    Deleted Messages.mbox
    Drafts.mbox
    Info.plist
    Junk.mbox
    Sent Messages.mbox
    Trash.mbox
    
  • change to the folder of the messages sent (note the backslash before the space) and list to see the files

    $ cd Sent\ Messages.mbox
    $ ls 
    CE7AE9-C83C-410A-9406-4DEFB7034
    Info.plist
    
  • the first file is a folder and contains all the messages and attachments in a series of subfolders. Now you will use the powerful unix find command to find all the files to be deleted and delete them.

  • the find command can recursively descends the directory tree to search files by name and by size (among other options), so if you know that the attachmentes to be deleted are PDF files with more than 200k you can use the first command to find and list the files. Then if it's ok, delete them with the second command. The second example will find and delete zip files with more than 1 MB.

    $ find . -iname "*.pdf" -size +200k
    ./77CE7AE9-C83C-410A-94/Data/Attachments/303/2/abc.pdf
    ./77CE7AE9-C83C-410A-94/Data/Attachments/305/2/xyz.pdf
    $ find . -iname "*.pdf" -size +200k -delete
    $ find . -iname "*.zip" -size +1M -delete
    
  • and if you want to delete all attachments bellow the present folder, you can use one simple command. To confirm that you are at the correct folder verify first printing the working directory. Then, remove every Attachments folders bellow it.

    $ pwd
    /Users/user/Library/Mail/v2/IMAP-info@furia.com.br@pop.furia.com.br/INBOX.mbox/Sent Messages.mbox
    $ find . -iname Attachments -exec rm -R {} +
    
  • repeat these operations on all mbox of the account