Bulk-fetching emails in the new Gmail API

后端 未结 2 1359
深忆病人
深忆病人 2020-12-06 04:19

I\'m using the python version of the newly released Gmail API by Google.

The following call returns just a list of message ids:

service.users().messa         


        
相关标签:
2条回答
  • 2020-12-06 04:52

    Here is an example of batch request in Java where I get all the threads using threads ids. This can be easily adapted for your need.

    BatchRequest b = service.batch();
    //callback function. (Can also define different callbacks for each request, as required)
    JsonBatchCallback<Thread> bc = new JsonBatchCallback<Thread>() {
    
        @Override
        public void onSuccess(Thread t, HttpHeaders responseHeaders)
                throws IOException {
            System.out.println(t.getMessages().get(0).getPayload().getBody().getData());
        }
    
        @Override
        public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders)
                throws IOException {
    
        }
    };
    
    // queuing requests on the batch requests
    for (Thread thread : threads) {
        service.users().threads().get("me", threads.getId()).queue(b, bc);
    }
    
    
    b.execute();
    
    0 讨论(0)
  • 2020-12-06 05:09

    Here is the solution that worked for me:

    batch = BatchHttpRequest()
    for msg_id in message_ids:
        batch.add(service.users().messages().get(userId='me', id=msg_id['id']), callback=mycallbackfunc)
    batch.execute()
    
    0 讨论(0)
提交回复
热议问题