Tôi muốn gửi email HTML cho người dùng sau khi họ đăng ký trang web. Trước đó, tôi đã viết kịch bản này để gửiGửi email HTML trong Appengine [PYTHON] bằng cách sử dụng tệp 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 <[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()
Nhưng thay vì đặt HTML trực tiếp vào mã chính, tôi muốn có tệp HTML riêng sẽ được sử dụng làm nội dung. Tôi đã cố gắng thực hiện như sau:
nhưng vô ích. Làm cách nào để sử dụng tệp HTML ở vị trí của mã HTML?
Bạn đã thử sử dụng các lệnh 'mở()' và '.readlines() hoặc .read()'? – Anthony