remove unused prototypes
This commit is contained in:
parent
d6449d7c25
commit
3fc00b1c5d
2 changed files with 0 additions and 49 deletions
|
|
@ -1,49 +0,0 @@
|
||||||
# %%
|
|
||||||
import email
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
from email.header import decode_header
|
|
||||||
from imaplib import IMAP4, IMAP4_SSL
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
# -------------------------------- credentials ------------------------------- #
|
|
||||||
|
|
||||||
cred_file = Path("../credentials.json")
|
|
||||||
with open(cred_file, "r") as f:
|
|
||||||
CREDENTIALS = json.load(f)
|
|
||||||
|
|
||||||
for key, value in CREDENTIALS.items():
|
|
||||||
os.environ[key] = value
|
|
||||||
|
|
||||||
IMAP_HOST = os.environ["IMAP_HOST"]
|
|
||||||
IMAP_PORT = os.environ["IMAP_PORT"]
|
|
||||||
IMAP_USER = os.environ["IMAP_USER"]
|
|
||||||
IMAP_PASS = os.environ["IMAP_PASS"]
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------- imap ----------------------------------- #
|
|
||||||
|
|
||||||
|
|
||||||
with IMAP4_SSL(host=IMAP_HOST) as imap_server:
|
|
||||||
imap_server.login(IMAP_USER, IMAP_PASS)
|
|
||||||
imap_server.select("INBOX")
|
|
||||||
|
|
||||||
# Search for all emails in the folder
|
|
||||||
status, email_ids = imap_server.search(None, "ALL")
|
|
||||||
email_ids = email_ids[0].split()
|
|
||||||
|
|
||||||
# Fetch email details using the retrieved IDs
|
|
||||||
for email_id in email_ids:
|
|
||||||
result, data = imap_server.fetch(email_id, "(RFC822)")
|
|
||||||
raw_email = data[0][1] # Raw content of the email
|
|
||||||
email_message = email.message_from_bytes(raw_email)
|
|
||||||
|
|
||||||
# Extract the subject
|
|
||||||
subject_encoded = email_message.get("Subject")
|
|
||||||
decoded_subject = decode_header(subject_encoded)[0][0]
|
|
||||||
|
|
||||||
if isinstance(decoded_subject, bytes):
|
|
||||||
decoded_subject = decoded_subject.decode()
|
|
||||||
|
|
||||||
# Print or use the subject as needed
|
|
||||||
print("Subject:", decoded_subject)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue