Mit Python Schaltfläche "klicken"

Ich versuche einige Analysen mit Python zu vereinfachen und will in dem Zuge eine Schaltfläche (Spaltentyp Schaltfläche) in meinen Tabellen aktivieren.
Ich finde allerdings nicht den passenden Befehl. Kann mir jemand weiterhelfen?

Hey,

Du kannst bei Schaltflächen eine Aktion “Skript” hinzufügen.

Hallo Sonja,

leider ist nicht möglich per Python Skript eine Schaltfläche zu triggern.

Kann die Aktion der Schaltfläche ggf. anders ausgeführt werden?

Vielen Dank für die schnelle Information.
Ja, ich kann theoretisch per Python die Aktion durchführen, allerdings klappt es irgendwie nicht, per Schaltfläche hat alles funktioniert.

Ich möchte eine Mail absenden, ich habe auch ein Skript dafür, aber ich bekomme die Fehlermeldung, dass keine Verbindung zum Email Server hergestellt werden kann.

error: Error: line 80, in smtp.connect(smtpserver) File “/usr/local/lib/python3.11/smtplib.py”, line 341, in connect self.sock = self._get_socket(host, port, self.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.11/smtplib.py”, line 312, in _get_socket return socket.create_connection((host, port), timeout, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.11/socket.py”, line 851, in create_connection raise exceptions[0] File “/usr/local/lib/python3.11/socket.py”, line 836, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

An den Email-Einstellungen sollte es nicht liegen, eher am Code, aber da muss ich mich erstmal auf Fehlersuche begeben. Ich habe ihn im Netz gefunden und angepasst, aber ich bin Python Anfänger.

Hier ist der Ausschnitt aus dem Code, der nicht funktioniert:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header
from urllib import parse
import requests
from seatable_api import Base, context

# SeaTable API authentication
base = Base(context.api_token, context.server_url)
base.auth()

# SMTP server configurations for sending emails
smtpserver = 'xxx'
username = 'xxx'
password = 'xxx'
sender = 'xxx'

receiver_rows = base.list_rows('Table1')
receivers = [row['mail'] for row in receiver_rows if row.get('mail')]

# Email subject
subject = 'SeaTable Send email'

# Constructing the email message
msg = MIMEMultipart('mixed')
msg['Subject'] = subject
msg['From'] = 'xxx'
msg['To'] = ";".join(receivers)

# HTML content for the email body
html = """
<html>
  <head></head>
  <body>
    <p>Hi!<br>
       xxx
    </p>
  </body>
</html>
"""
text_html = MIMEText(html,'html', 'utf-8')
msg.attach(text_html)

# Sending the email using SMTP

# => Hier ist Zeile 80
smtp = smtplib.SMTP()
smtp.connect(smtpserver)
smtp.login(username, password)
smtp.sendmail(sender, receivers, msg.as_string())
smtp.quit()