I am attempting to launch the local mail application, Outlook 365 on windows and Mail on MacOS, and start a blank email, with the (To: ) column filled in from a database query.
Ideally it would look something similar to:
def email_create():
if MacOS:
open Mail.App
To: = [sql statement]
if Windows
open Outlook.application
To: = [sql statement]
EDIT: With the help of @spYder below, I wanted to just post my final product that seems to work great. Thank you again @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)
For windows outlook you would just replace the ',' with ';' because of the way email addresses are separated. My last step now is I just need to figure out how to identify if the user is using MacOS or Windows.