How To Retrieve Blocked Gmail Attachments

If you’re like me, then you constantly find yourself sending email attachments to yourself as a mode of backup for miscellaneous files. And if you use Gmail, there will be instances when you can’t retrieve those attachments because Gmail blocks downloads of potentially harmful files.

Though Gmail does prevent you from attaching those potentially harmful files (like *.exe) to begin with, they do manage to slip past the upload scan at times, especially if they’re compressed. This is fine so long as you’re still able to download them, but sadly that isn’t always the case.

So what do you do when you need to download a backup file that Gmail has blocked you from downloading, and you’ve lost the original? Luckily, there is a workaround and all is not lost. I will demonstrate with an example below, where I needed to retrieve a *.rar file that contained an executable file.


1. Firstly, download Python v3.4.2 from here. Once you’ve downloaded the file, install the program by running the file and following the on screen instructions.


2. Open your email, and click on Show original from the drop-down menu.


3. A pop-up will appear with what appears to be garbled text. This is actually your email and attachment as a text file, encoded in base64. We will use a Python script to convert it back to binary. Copy the entire text to clipboard (Ctrl+A, Ctrl+C).


4. Paste it in a text file and save it with any generic name ending in *.txt.


5. Do the same for the script file, copy the script below:

6. Paste it in a text file.


7. Save it in the same folder with any generic name ending in *.py and Python should automatically recognise it as a Python script. If you can’t modify the file extension, you have to unhide known file extensions in Windows Explorer.


8. Run the Python script, and press Enter when prompted.


9. Depending on the file size, the attachment should appear immediately in the same location as the script and text file.


That’s it. The script works with Python 3.4.2 and can process multiple files and warns before overwriting anything.

Credits to Stefan for providing the script.

20 thoughts on “How To Retrieve Blocked Gmail Attachments

  1. Ferenc

    Hi Stefan – Congrats for your work, it surely solved a tough problem. I would ask you however one question if you do not mind regarding this script – how long it took you to come with such a good solution?

  2. Pingback: how to open Gmail block file ? | androidfreetutorial


    Really fantastic extract the gmail blocked file…superb work
    thank u……………


Leave a Reply

Your email address will not be published. Required fields are marked *