Htmlbody kompiliert bei der Generierung einer Outlook -E -Mail nicht in Python

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Htmlbody kompiliert bei der Generierung einer Outlook -E -Mail nicht in Python

by Anonymous » 10 Feb 2025, 18:16

Ich schreibe ein Python-Modul, um eine Outlook-E-Mail mit einem Anhang mit Win32com zu generieren. Alle funktionieren einwandfrei, bis auf die Formatierung des HTMLBody. Soweit ich recherchiert habe, ist es
unmöglich, die Vorabformatierung des HTMLBody in Python durchzuführen. Sie können es nur in HTML tun. Ich habe den Code des folgenden Links verwendet, da mein Hauptanliegen darin bestand, dass mein Körper das aktuelle Datum und die aktuelle Uhrzeit hat, wenn eine E-Mail generiert wird https://www.geeksforgeks.org/html-datetime-attribute/.
def __Emailer(subject, recipient, cc, auto=True):
import win32com.client as win32

outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.CC = cc
mail.Subject = subject

mail.HTMLBody = """




GeeksforGeeks
Approach 2: Using <time> Tag with JavaScript



function updateTime() {
const now = new Date();
const timeElement = document.getElementById("current-time");
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
timeElement.dateTime = now.toISOString();
timeElement.innerHTML = 'Today is: ${now.toLocaleDateString(undefined, options)},
Time: ${now.toLocaleTimeString()'};
}

setInterval(updateTime, 1000);
updateTime();







"""

mail.Attachments.Add(Source=r"C:\Users\project.xlsx")

if auto:
mail.Display(True)

else:
mail.open
< /code>
Aber in meiner Ausgabe erhalte ich nur diese H1- und H3 -Zeilen. Grundsätzlich funktioniert das Innere des nicht. Ausgabe)

Top