Chcę wysłać wiadomość e-mail w formacie HTML użytkownikom po zarejestrowaniu się w witrynie. Wcześniej napisałem skrypt do wysyłaniaWysyłaj wiadomość HTML w aplikacji Appengine [PYTHON] przy użyciu pliku HTML
from google.appengine.api import mail
message = mail.EmailMessage(sender="Example.com Support <[email protected]>",
subject="Your account has been approved")
message.to = "Albert Johnson <Albert[email protected]>"
message.body = """
Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
"""
message.html = """
<html><head></head><body>
Dear Albert:
Your example.com account has been approved. You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.
Please let us know if you have any questions.
The example.com Team
</body></html>
"""
message.send()
Ale zamiast umieszczenie HTML bezpośrednio w głównym kodzie, chcę mieć oddzielny plik HTML, który będzie używany jako ciało. Próbowałem zrobić to w następujący sposób:
message.html = 'emailHTML.html'
, ale na próżno. Jak mogę użyć pliku HTML zamiast kodu HTML?
Czy próbowałeś użyć poleceń 'open()' i '.readlines() lub .read()'? – Anthony