If you’re in the Gmail ecosystem you’ve already forfeited your data. I could ask why you would bother writing code when the mail service provides a way to do what you want without firing up a python console.