pre eliminazione gestione allegati

This commit is contained in:
Alessandro Battilani
2026-01-15 09:53:03 +01:00
parent 1868859800
commit 7282352401
2 changed files with 13 additions and 1 deletions

1
ArchiviaEmail.bat Normal file
View File

@@ -0,0 +1 @@
uv run .\ArchiviazioneMail.py

View File

@@ -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: