Looking for a way to use custom branding for emails sent by Swimlane rather than just plain text
Anyone got any ideas or suggestions
Cheers
John
Looking for a way to use custom branding for emails sent by Swimlane rather than just plain text
Anyone got any ideas or suggestions
Cheers
John
@jgannon I have personally seen using a Python task to create a HTMl body string for an email message as well as sending it via that task within Swimlane. Here’s is an example Python class to do this:
import json
import requests
import pendulum
import cgi, time
import smtplib
############ EMAIL NOTIFICATION VARIABLES ###################
__SMTP__PORT__ = 25
__SMTP_SERVER__ = sw_context.inputs['smtp_server']
__SMTP_USER__ = sw_context.inputs['smtp_user']
__SMTP_PASS__ = sw_context.inputs['smtp_pass']
############ EMAIL NOTIFICATION VARIABLES ###################
def convert_timestamp_string(timestamp):
print(timestamp)
try:
dt = pendulum.parse(timestamp[:-1])
except:
dt = None
return dt
class ManagerNotification(object):
def __init__(self, id):
self.id = id
@property
def id(self):
return self._id
@id.setter
def id(self, value):
self._id = value
@property
def emailBody(self):
return self._emailBody
@emailBody.setter
def emailBody(self, value):
email_address = value[0]
full_name = value[1]
app_name = value[2]
last_login = value[3]
self._emailBody = '''Hello, you are identified as the manager of %s (%s).
Your information security team has identified that %s has not logged in to their %s account since %s.
Based on our organizational goals of reducing costs of unused accounts, please reply to this email and let us know if this account can be deleted or is still being used.
Thank you,
Office of the Chief Information Security Officer
''' % (full_name, email_address, full_name, app_name, last_login)
@property
def to(self):
return self._to
@to.setter
def to(self, value):
self._to = value
@property
def sender(self):
return self._sender
@sender.setter
def sender(self, value):
self._sender = value
@property
def subject(self):
return self._subject
@subject.setter
def subject(self, value):
self._subject = value
def send(self):
# Prepare actual message
message = """From: %s\nTo: %s\nSubject: %s\n\n%s
""" % (self.sender, ", ".join(self.to), self.subject, self.emailBody)
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(__SMTP_USER__, __SMTP_PASS__)
server.sendmail(self.sender, self.to, self.emailBody)
server.close()
print 'successfully sent the mail'
except:
print "failed to send mail"
He had the same need… We developed a little webservice using python Flask that builds an entire Multipart-MIME HTML email notification, there you have a great control of the format and content. It could be great to have an email notification editor like the app builder, a drag-n-drop interface that helps us build whichever mail layout we want.