How to retrieve email from sent (google api)

Viewed 85

I want to get an email from my gmail sent items via c#. I used this

service.Users.Messages.Get("me",id);

but it get 404 error. All other apis works properly. Thanks.

1 Answers

404 means that the Id you are requesting does not exist. I would run a List first then a get after.

If you want to see messages that are in the sent folder you should do a message.list and search for what is in the sent folder.

var request = service.Users.Messages.List("me");
request.Q = "is:sent";
var result = request.Execute();

If you know when it was sent you could add a date.

var request = service.Users.Messages.List("me");
request.Q = "is:sent  after:2021/3/28 before:2021/3/31";
var result = request.Execute();

Tip Q works just like the search function in the Gmail web application so if you can get that to return what you want just add it to Q

enter image description here

Related