I am creating a web application with ASP .Net WEB API for integrating GMail API.
I am reading threads then reading messages on each thread id with a loop of threads.
It is taking too much loading to get response. Please help me if i did anything wrong.
And i want to know the beast process to read and display messages (gmail mails) in Front end (browser).
What I have tried:
ListRequest req = gs.Users.Threads.List(me);
req.LabelIds = "INBOX";
req.MaxResults = 50;
res threadResponse = req.Execute();
foreach (Thread eachThread in res.Threads)
{
GetRequest req = gs.Users.Threads.Get(EmailAddress, eachThread.Id);
req.Format = ThreadsResource.GetRequest.FormatEnum.Metadata;
List<string> metaData = new List<string>() { "From", "Date", "Subject" };
req.MetadataHeaders = metaData;
req.Fields = "id, messages(id,labelIds/*,payload/headers(name,value))";
Thread thcon = req.Execute();
Message lmsg = thcon.Messages.LastOrDefault();
EmailList.Add(lmsg);
}