pre eliminazione gestione allegati
This commit is contained in:
1
ArchiviaEmail.bat
Normal file
1
ArchiviaEmail.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uv run .\ArchiviazioneMail.py
|
||||||
@@ -21,7 +21,7 @@ ONEDRIVE_PATH = r"C:\Users\U086304\OneDrive - Intesa SanPaolo\Allegati_Outlook"
|
|||||||
if not os.path.exists(ONEDRIVE_PATH):
|
if not os.path.exists(ONEDRIVE_PATH):
|
||||||
os.makedirs(ONEDRIVE_PATH)
|
os.makedirs(ONEDRIVE_PATH)
|
||||||
print(f"Cartella creata: {ONEDRIVE_PATH}")
|
print(f"Cartella creata: {ONEDRIVE_PATH}")
|
||||||
MONTHS_LIMIT = 5
|
MONTHS_LIMIT = 3
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
def get_file_hash(file_path):
|
def get_file_hash(file_path):
|
||||||
@@ -31,6 +31,12 @@ def get_file_hash(file_path):
|
|||||||
hasher.update(chunk)
|
hasher.update(chunk)
|
||||||
return hasher.hexdigest()
|
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():
|
def main():
|
||||||
if not os.path.exists(ONEDRIVE_PATH):
|
if not os.path.exists(ONEDRIVE_PATH):
|
||||||
os.makedirs(ONEDRIVE_PATH)
|
os.makedirs(ONEDRIVE_PATH)
|
||||||
@@ -39,6 +45,11 @@ def main():
|
|||||||
try:
|
try:
|
||||||
outlook = win32com.client.Dispatch("Outlook.Application")
|
outlook = win32com.client.Dispatch("Outlook.Application")
|
||||||
namespace = outlook.GetNamespace("MAPI")
|
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)
|
inbox = namespace.GetDefaultFolder(6)
|
||||||
archive_root = namespace.Folders.Item(ARCHIVE_NAME)
|
archive_root = namespace.Folders.Item(ARCHIVE_NAME)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user