def get(self): current_user = users.get_current_user() current_email = current_user.email() emailAddr = self.request.get('email') contextIO = ContextIO(api_key=settings.CONTEXTIO_OAUTH_KEY, api_secret=settings.CONTEXTIO_OAUTH_SECRET, api_url=settings.CONTEXTIO_API_URL) response = contextIO.contactfiles(emailAddr,account=current_email) self.response.out.write(simplejson.dumps(response.get_data()))
mailbox_to_query = '*****@*****.**' api_client = ContextIO(api_key=api_key, api_secret=api_secret) # EXAMPLE 1 # Print the subject line of the last 20 emails sent to with [email protected] response = api_client.contactmessages(account=mailbox_to_query,to_address='*****@*****.**',limit=20) for message in response.get_data(): print 'Subject %s' % message['subject'] # EXAMPLE 2 # Download all versions of the last 2 attachments exchanged with [email protected] response = api_client.contactfiles(account=mailbox_to_query,email='*****@*****.**',limit=2) for document in response.get_data(): print "Downloading all versions of document %s" % document['fileName'] for attachment in document['occurences']: file_response = api_client.downloadfile(file_id=attachment['fileId']) file_content_type = file_response.get_content_type() fileobj = open(attachment['fileName'], mode="wb") fileobj.write(file_response.get_content()) fileobj.close() # EXAMPLE 3 # Download all attachments with a file name that contains the word 'proposal' print "Downloading all attachments matching 'proposal'\n"