Hello Mark,
I tweaked the code for Inbound Email parsing script and now able to get the reply back on the same Data Table, Thanks for your support as always.
In case if any one would like to have it the same way, below is the code that I have changed.
uuids = re.search(r'\[.*?\]', emailmessage.subject)
search_val = ""
incidents = ""
if uuids:
log.info(uuids.group())
search_val_1 = uuids.group()
search_val_2 = search_val_1.replace("[","")
search_val = search_val_2.replace("]","")
log.info(search_val)
else:
search_val = newIncidentTitle
if uuids:
query_builder.contains(fields.incident.id, int(search_val))
query_builder.equals(fields.incident.plan_status, "Active")
query = query_builder.build()
incidents = helper.findIncidents(query)
else:
query_builder.equals(fields.incident.name, newIncidentTitle)
query_builder.equals(fields.incident.plan_status, "Active")
query = query_builder.build()
incidents = helper.findIncidents(query)
Also when the "From" column will be updated with
Lastname, Firstname <firstname.lastname@example.com> by this way when you try to reply back using the workflow from the Data Table it will give an error as the pre process script only ask for the
firstname.lastname@example.com.
For this also have made a small change in the same script which is as below.
@staticmethod
def add_email_conversation(headers, msg_body, msg_attachments):
# attempt to add to incident datatable, if present
def handle_list(value):
# convert a list to comma separate list, if neccessary
if value and isinstance(value, list):
return ", ".join(value)
return value
def convert_from(mail_):
sub1 = "<"
sub2 = ">"
# getting index of substrings
if "<" in mail_[0]:
idx1 = mail_[0].index(sub1)
idx2 = mail_[0].index(sub2)
res = mail_[0][idx1 + len(sub1) + 0: idx2]
return res
return mail_[0]I am stuck at one point, The mail_body when we are using the workflow/ Function outbound Email : Email send is only having Text field, how can we change it to Rich Text format. If we create a new field it is not working. The reply workflow does have this filed as Rich text. Any suggestions would help.
Thanks again.
------------------------------
Srinivas Joshi
SrinivasJoshi
------------------------------
Original Message:
Sent: Wed November 16, 2022 08:48 AM
From: Mark Scherfling
Subject: Outbound Email Integration Question
Hi Srinivas,
As you stated, the logic in the generic email parsing script is to track incoming email messages against existing incidents by looking for incidents with the same title as the email subject. Take a look at the script used in the Email Approval Process content pack for inbound messages. It parses the email for incident Id in order to craft a similar query_builder query to instead look up the incident by id.
Each email has a section like the following in the email body for tracking incident information:
##- retain this data -##
msg-id: 98cc1ca81d6b-d31547c58714-d575453904dc-092677cc4c10-620980ac83ffd7a2
incident 2204: email approval (link)
task 2238: test outlook (link)
expiration 1666790100000: 2022-10-26 14:15:00 IST
------------------------------
Mark Scherfling
------------------------------