From f32147c25a6b17db8eed8a98ca94e1d808eb9340 Mon Sep 17 00:00:00 2001 From: Cyril Novel Date: Sun, 30 Aug 2020 14:41:39 +0200 Subject: [PATCH] Fix template open --- src/email_sender.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/email_sender.py b/src/email_sender.py index ecdbefc..514ca38 100644 --- a/src/email_sender.py +++ b/src/email_sender.py @@ -6,6 +6,7 @@ from smtplib import SMTP_SSL from argparse import ArgumentParser from datetime import date, timedelta import wikiquote +import os from event import create_events_from_span @@ -78,7 +79,9 @@ class EmailSender: def create_html_templated(events_previous, events_current, events_next): - with open('../html_template/mail.html', 'r', encoding='utf-8') as tmp: + directory = os.path.dirname(os.path.realpath(__file__)) + template_path = os.path.join(directory, '..', 'html_template', 'mail.html') + with open(template_path, 'r', encoding='utf-8') as tmp: mail = tmp.read() mail = mail.replace('{LogoAddress}', 'http://xerto.free.fr/Paturlettre/LogoLettre.png')