public static void DeleteAllUnreadMessages() { Credential = Preparation.GetUserCredential(); var messages = Messages.ListMessages(Preparation.GetService(Credential), User, "in:inbox is:unread"); if (!messages.Any()) { return; } foreach (var message in messages) { Messages.DeleteMessage(Service, User, message.Id); } }
static Gmail() { Credential = Preparation.GetUserCredential(); Service = Preparation.GetService(Credential); }