Download Gmail Blocked Email Attachments

Anti-virus warning – 1 attachment contains a virus or blocked file. Downloading this attachment is disabled.

blocked-attachment

Gmail says …. File types you can’t include as attachments
.ADE, .ADP, .BAT, .CHM, .CMD, .COM, .CPL, .EXE, .HTA, .INS, .ISP, .JAR, .JS (NEW), .JSE, .LIB, .LNK, .MDE, .MSC, .MSI, .MSP, .MST, .NSH .PIF, .SCR, .SCT, .SHB, .SYS, .VB, .VBE, .VBS, .VXD, .WSC, .WSF, .WSH

I know my zip file “portfolio-1.zip” have .JS files

Note: Gmail warned you that attachment is not safe. So make 100% sure that email attachments is safe for download before follow below process.

email-show-original

Click on email option “Show original”, it will open a new browser window with MIME encoded message. Now you have to “Download Original” OR “Copy to clipboard” save text file “original_msg.txt”

In file “original_msg.txt” you can find attached file name

Content-Type: application/zip; name=”portfolio-1.zip”
Content-Disposition: attachment; filename=”portfolio-1.zip”
Content-Transfer-Encoding: base64
X-Attachment-Id: f_iqui8p0t0

Create new Python script named “getAttachments.py” and write below code in it

import email
import sys

if __name__=='__main__':
    if len(sys.argv)<2:
        print "Please enter a file to extract attachments from"
        sys.exit(1)

    msg = email.message_from_file(open(sys.argv[1]))
    for pl in msg.get_payload():
        if pl.get_filename(): # if it is an attachment
            open(pl.get_filename(), 'wb').write(pl.get_payload(decode=True))

D:\>python –version
Python 2.7.6

D:\>python getAttachments.py original_msg.txt

You will find zip file attachment “portfolio-1.zip” in the same folder!

You can also open Mime Encoded Text file “original_msg.txt” in Outlook or any email client just rename it to “original_msg.eml” then open email file and download attachment.

Suggestion: If your files are safe, you can upload the file to Google Drive, then send shareable link as Drive attachment.

Extract attachments from emails that Gmail doesn’t allow you to download.