我正在尝试启动本地邮件应用程序、Windows 上的 Outlook 365 和 MacOS 上的 Mail,并启动一封空白电子邮件,其中 (To: ) 列从数据库查询中填写。
理想情况下,它看起来类似于:
def email_create():
if MacOS:
open Mail.App
To: = [sql statement]
if Windows
open Outlook.application
To: = [sql statement]
编辑:在下面@spYder 的帮助下,我只想发布我的最终产品,看起来效果很好。再次感谢@spYder。
import webbrowser
def send_email_command():
sql = "SELECT EMAIL_PRIMARY FROM USER_INFORMATION"
cursor.execute(sql)
results = ','.join([item for row in [list(i) for i in (cursor.fetchall())] for item in row]) # creates the comma separated list from my query
webbrowser.open('mailto: ' + results, new=1)
对于 Windows Outlook,您只需将 ',' 替换为 ';' 因为电子邮件地址是分开的。我现在的最后一步是我只需要弄清楚如何识别用户使用的是 MacOS 还是 Windows。
牛魔王的故事
相关分类