Downloading Block Gmail attachment

For page specific messages
For page author info

Python script for downloading block Gmail attachment




Open your mail, click on show original. It will open a new window with a text document. Save this to .txt format. Now save below code with .py format. Run the code you get your block attachment in your present floder/directory.

Suppose, you save the below file with Next, you save the original mail with mail.txt. Now, you run like mail.txt. It will extract your attachment from mail.txt....WinkSmile    

import email
import sys

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

    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))


  • No Sign up needed. Free access to content, authoring templates & tools.
  • Account needed only to post comments or to author content.
  • Sign up with just e-mail address.
  • Your mail filter might take 0space mails as spam. Check SPAM mail folder and change settings if needed.