1

I want to access currently sent/received mails from mailbox. I had done some coding but it is not giving me only latest arrived mails in mailbox, it gives me 2 days old mails even if by applying filter to fire query of date as from-to and specifying to date as currently date on the system. What should i do to get current mails from mailbox by applying filter of date and time.

dtTimeTo.Value = DateTime.Now;
string query = "after: " + fromDate.Date.ToString("yyyy/MM/dd") + " before: " + toDate.Date.ToString("yyyy/MM/dd") + " label: " + labelName; 
UsersResource.MessagesResource.ListRequest request = service.Users.Messages.List(userId);
request.Q = query;
ListMessagesResponse response = request.Execute();  
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • Do you have any code snippet. Please show us. – Shoaib Adil Jul 11 '18 at 12:02
  • Could you please include the relevant parts of your code? – tbrk Jul 11 '18 at 12:02
  • I would use imap, check stackoverflow for imap+google. For example [this question](https://stackoverflow.com/questions/7056715/reading-emails-from-gmail-in-c-sharp) – Cleptus Jul 11 '18 at 12:26
  • dtTimeTo.Value = DateTime.Now; string query = "after: " + fromDate.Date.ToString("yyyy/MM/dd") + " before: " + toDate.Date.ToString("yyyy/MM/dd") + " label: " + labelName; UsersResource.MessagesResource.ListRequest request = service.Users.Messages.List(userId); request.Q = query; ListMessagesResponse response = request.Execute(); – Sushama phalake Jul 11 '18 at 12:35
  • 1
    Try building up your string and then putting it in the search box in Gmail to test it you will be able to find errors easier that way **after: 2018/07/09 before: 2018/07/10 label:unread** – Linda Lawton - DaImTo Jul 11 '18 at 13:00

0 Answers0