<s> import os <EOL> import time <EOL> from nylas import APIClient <EOL> from nylas . util import generate_id <EOL> APP_ID = '<STR_LIT>' <EOL> APP_SECRET = '<STR_LIT>' <EOL> ACCESS_TOKEN = '<STR_LIT>' <EOL> client = APIClient ( APP_ID , APP_SECRET , ACCESS_TOKEN ) <EOL> subject = generate_id ( ) <EOL> draft = client . drafts . create ( ) <EOL> draft . to = [ { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:email>' : '<STR_LIT>' } ] <EOL> draft . subject = subject <EOL> draft . body = "<STR_LIT>" <EOL> for filename in filter ( lambda x : not os . path . isdir ( x ) , os . listdir ( "<STR_LIT:.>" ) ) : <EOL> f = open ( filename , '<STR_LIT:r>' ) <EOL> attachment = client . files . create ( ) <EOL> attachment . filename = filename <EOL> attachment . stream = f <EOL> attachment . save ( ) <EOL> draft . attach ( attachment ) <EOL> draft . send ( ) <EOL> th = client . threads . where ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : subject } ) . first ( ) <EOL> while not th : <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> th = client . threads . where ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : subject } ) . first ( ) <EOL> print th . messages [ <NUM_LIT:0> ] . attachments [ <NUM_LIT:0> ] . download ( ) </s>
