I have a Python function that returns an array. I'd like to print the array within the body of a HTML email but I can't figure out how to execute Python within HTML.This is the HTML element of my email script...
html = """<html><head></head><body> <p>These are the available dates: </p><%= avDates() %></body></html>"""
...the email executes fine, I'm receiving mail, but the function prints out as text ("<%= avDates() %>" is shown in the email). How do I get this to work?
UpdateI've changed the code to the following as per @Francesco's suggestion - it makes sense to me but the script now sends me a black email body (contains one " character) and the array is sent to the shell...
date_list = avDates()date_list_string = ' '.join(date_list)html = """<html><head></head><body> <p>These are the available dates: </p>""" + date_list_string + """"</body></html>"""
Best Answer
I would construct a string with the dates and then insert into your html:
date_list = avDates()date_list_string = ' '.join(date_list) # edit this to match the desired outputhtml = """<html><head></head><body> <p>These are the available dates: </p>""" + date_list_string + """"</body></html>"""
I think the problem is with the array and not with the email script - I'm going to close this and post a different question.