From 72823524014a4fb371c384e70b31ba3e3338f931 Mon Sep 17 00:00:00 2001 From: Alessandro Battilani Date: Thu, 15 Jan 2026 09:53:03 +0100 Subject: [PATCH] pre eliminazione gestione allegati --- ArchiviaEmail.bat | 1 + ArchiviazioneMail.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 ArchiviaEmail.bat diff --git a/ArchiviaEmail.bat b/ArchiviaEmail.bat new file mode 100644 index 0000000..8666cd4 --- /dev/null +++ b/ArchiviaEmail.bat @@ -0,0 +1 @@ +uv run .\ArchiviazioneMail.py \ No newline at end of file diff --git a/ArchiviazioneMail.py b/ArchiviazioneMail.py index 7790610..429534a 100644 --- a/ArchiviazioneMail.py +++ b/ArchiviazioneMail.py @@ -21,7 +21,7 @@ ONEDRIVE_PATH = r"C:\Users\U086304\OneDrive - Intesa SanPaolo\Allegati_Outlook" if not os.path.exists(ONEDRIVE_PATH): os.makedirs(ONEDRIVE_PATH) print(f"Cartella creata: {ONEDRIVE_PATH}") -MONTHS_LIMIT = 5 +MONTHS_LIMIT = 3 # ---------------------- def get_file_hash(file_path): @@ -31,6 +31,12 @@ def get_file_hash(file_path): hasher.update(chunk) return hasher.hexdigest() +def mostra_cartelle(folder_object, indent=""): + for folder in folder_object.Folders: + print(f"{indent}{folder.Name}") + # Richiama se stessa per cercare sottocartelle + mostra_cartelle(folder, indent + " ") + def main(): if not os.path.exists(ONEDRIVE_PATH): os.makedirs(ONEDRIVE_PATH) @@ -39,6 +45,11 @@ def main(): try: outlook = win32com.client.Dispatch("Outlook.Application") namespace = outlook.GetNamespace("MAPI") + + # Partendo dalla radice dell'account predefinito + # root = namespace.GetDefaultFolder(6).Parent + # mostra_cartelle(root) + email_sent = namespace.GetDefaultFolder(5) inbox = namespace.GetDefaultFolder(6) archive_root = namespace.Folders.Item(ARCHIVE_NAME) except Exception as e: