Hi There -
Can someone help me add the 'Body' (or whatever it's called) parameter in the send_email definition from the Functions.py script?
# ------------------ Function to send mail -------------------
# sent to and ccAdd should be commma seperated email strings
# configuration is a dictionary
def send_mail(configuration,subject,text, toAdd=None,ccAdd=None):
server = configuration['server']
port = configuration['port']
username = configuration['username']
password = configuration['password']
fromAdd = configuration['send_from']
if toAdd is None:
send_to=configuration['toAddress']
else:
send_to=toAdd
if isinstance(send_to,list):
send_to = ",".join(send_to)
if isinstance(ccAdd,list):
ccAdd = ",".join(ccAdd)
send_toList = send_to.split(',')
if ccAdd is not None:
ccAddList=ccAdd.split(',')
else:
ccAdd=''
ccAddList=[]
try:
msg = MIMEMultipart()
msg['From'] = fromAdd
msg['To'] = send_to
msg['CC'] = ccAdd
msg['Date'] = formatdate(localtime=True)
msg['Subject'] = subject
msg.attach(MIMEText(text,'html'))
send_toList = send_toList + ccAddList
smtp = smtplib.SMTP(server, port)
smtp.login(username, password) #uncomment if required
smtp.sendmail(fromAdd, send_toList, msg.as_string())
q = "Successfully sent email"
except SMTPException as error:
q = "Error: unable to send email : {err}".format(err=error)
#This message will appear in the Request History and can be modified based on requirement.
finally:
smtp.close()
return q
Thanks!