deletes email after download

This commit is contained in:
maru21 2024-11-13 16:51:53 +01:00
parent 28fe200923
commit ecbdaaa5f6

View File

@ -1,4 +1,3 @@
import os
import base64
import requests
@ -91,6 +90,10 @@ def process_email(service, message):
if link:
pdf_link = link.get("href")
download_pdf(pdf_link)
# After successful download, delete the email
service.users().messages().delete(userId='me', id=message['id']).execute()
logging.info(f"Email with ID {message['id']} successfully deleted after PDF download.")
else:
logging.info("No 'PDF herunterladen' link found in this email.")
except Exception as error: