Time Machine in macOS can work within a number of apps, letting you retrieve older versions of files or even deleted email messages in the Mail app. However, if an entire folder of stuff goes away, you need to turn to the Finder.
Macworld reader Harold found himself in this pinch, because a folder that contains all his business emails disappeared from Mail without any action on his part that he’s aware of. He first tried to use Time Machine within Mail, opening Mail, then choosing Enter Time Machine from the Time Machine system menu item. Every time he did so, Mail quit!
If you’re using IMAP, a protocol for syncing messages with a remote server to a local app’s mailbox, it’s possible to recover it that way, assuming the deletion didn’t propagate to the server, too. You should be able to select in Mail: Mailbox > Synchronize > Mail name, and this will restore access to the messages.