Try ERPNext Buy Support Partners Foundation

Issue with Gmail Integration, Having issues with SENT messages

I found this for sent messages:
def get_email_sent_threads(user_id=‘me’):
service = start_gmail_service()
results = service.users().messages().list(userId=user_id,labelIds = [‘SENT’]).execute()
messages = results.get(‘messages’, [])
if not messages:
frappe.throw(_(“No messages found.”))
return messages

But it only gives the id for messages
Then I need to run this:
for message in messages:
msg = service.users().messages().get(userId=‘me’, id=message[‘id’]).execute()

for data from messages but this is taking too much time and server is throwing time out. Do we have better approach?