Parsing text from mailhook to variables or collection

I am having difficulty finding a module (or modules) to use for the following:

Use Case:
Action: FORWARDED email received by custom mailhook, which includes an array of Attachments.
Goal: PUT those attachments to an S3 bucket.

Workflow: Mailhook → Iterator → S3 module.

The set-up works as expected for iterating the attachments, as they are already present as an array.

I would like to add the following:
parse out one or more extra block(s) of added text from the mailhook’s TEXT mapping field - ie:

FromV: Fred Flinstone
SubjectV: FW Rubber Tires
DateV: <datestring>

(Why? because forwarded messages appear not to pass the original sender or received date.)

the text string is:

Begin forwarded message:

From: Fred Flinstone
Subject: FW Rubber Tires
To: somebody@somewhere

more message text more message text…

idea is to parse the text block into a collection or array item for follow-on use, or at least into multiple items:

Data: {
    FromV: "Fred Flinstone",
    SubjectV: "FW Rubber Tires",
    DateV: somedate


variable "FromVar" = "Fred Flinstone" (as a regex replace of FromV...)
variable "SubjectVar" = "FW Rubber Tires"
... and so on

in order to use them as additional headers in the S3 module - ie:

header name: x-amz-meta-from; value: Data.From;

I am currently parsing a value out of the mailhook Text item using Replace() in the Folder field of the s3 module, but that’s pretty hacky. So it seems is using text parser n times… can’t figure out proper regex capture for set multiple variables.

Ideally, I would like to build a simple array item to map into the S3 module:

Data [
    {"From" : "Fred Flinstone"},
    {"Subject" : "FW Rubber Tires"},
    {"Date" : "somedate"}

Hoping to find a combo of modules in-between to do the conversion. Any thoughts would be helpful. Thanks!

1 Like