Notices
 

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 extract.py. Next, you save the original mail with mail.txt. Now, you run like extract.py 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"
        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))
 
X