reading Simple Mail Transfer Protocol (SMTP) – Extension: Send latest reports January 28, 2024 by Akarsh Ahluwalia No Comments Simple Mail Transfer Protocol (SMTP) – Extension: Send latest reports [Python] Plain text view Copy the code ? 1 2 3 # Os.path. getmtime in Python allows you to check the time when the file was created and send the latest report import os print (os.path.getmtime( "./report/ test report.html" )) Implementation: [Python] Plain text view Copy the code ? 1 2 3 4 5 6 import os Fetch the list of file names in the folder list_filename = os.listdir( "./report" ) print (list_filename) list_filename.sort(key = lambda x:os.path.getmtime( "./report/" + x),reverse = True ) print ( "The latest file name is:" ,list_filename[ 0 ]) ItheimaGZ (itheimaGZ)