HTML-table as variable in HTML-mail?
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
HTML-table as variable in HTML-mail?
Hi!
I have a (variable) html table (as a html file) that I want to embed as a part of a html email in Switch. The email html has other Switch variables in it, but I can't figure out how to embed my table. Any suggestions?
ps. I also have the table as a CSV if that can be used some how.
I have a (variable) html table (as a html file) that I want to embed as a part of a html email in Switch. The email html has other Switch variables in it, but I can't figure out how to embed my table. Any suggestions?
ps. I also have the table as a CSV if that can be used some how.
Re: HTML-table as variable in HTML-mail?
Put the HTML of the table in private data and place that variable in your HTML template.
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTML-table as variable in HTML-mail?
Any suggestion how? The HTML-table is a file, not metadata.
- JimmyHartington
- Advanced member
- Posts: 316
- Joined: Tue Mar 22, 2011 7:38 am
Re: HTML-table as variable in HTML-mail?
Could you read it in as Privatedata.
Re: HTML-table as variable in HTML-mail?
I have not tested it, but I think the "Create file from template" app can insert a file into a file.
- JimmyHartington
- Advanced member
- Posts: 316
- Joined: Tue Mar 22, 2011 7:38 am
Re: HTML-table as variable in HTML-mail?
I have this legacy script-code I have used earlier.
Code: Select all
/*
This script reads the body of a file to private data.
*/
function jobArrived( s : Switch, job : Job )
{
// Set some property stuff
if(s.getPropertyValue('Debug') == 'Yes'){
var debug = true;
} else {
var debug = false;
}
if(job.isFile())
{
// Make temp file
var htmlData = File.read(job.getPath(), "UTF-8");
// Set to PD
job.setPrivateData("text", htmlData);
// Debug
s.log(1, 'TXT: ' + htmlData);
// Send along
job.sendToSingle(job.getPath());
} else {
// Not supporting folders
if(debug) s.log(2, 'Input job was folder.');
}
}
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTML-table as variable in HTML-mail?
Thanks Jimmy, but unfortunatly I do not have the scripting module.
What I need is to just copy the text from the html-file and insert as PrivateData, but maybe thats not possible without the scripting module?
Maybe someone can build the app: 'Text file 2 PrivateData'
What I need is to just copy the text from the html-file and insert as PrivateData, but maybe thats not possible without the scripting module?
Maybe someone can build the app: 'Text file 2 PrivateData'
Re: HTML-table as variable in HTML-mail?
Are you on windows or mac?
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTML-table as variable in HTML-mail?
You can use the "Run Command" App to achieve this. You can use either Cmd or PowerShell:
In Cmd using the type command:
In powershell using the Get-Content command: The path to the text file can be set via variables of course. The content will be in the FileContent Private Data field.
In Cmd using the type command:
In powershell using the Get-Content command: The path to the text file can be set via variables of course. The content will be in the FileContent Private Data field.
- JimmyHartington
- Advanced member
- Posts: 316
- Joined: Tue Mar 22, 2011 7:38 am
Re: HTML-table as variable in HTML-mail?
Thanks! The solution is not very elegant, but it works
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: HTML-table as variable in HTML-mail?
Thanks, it works great!
I ended up using Command Promt and command:
Code: Select all
type "%%InputFilePath%%"
-
- Newbie
- Posts: 8
- Joined: Mon Apr 17, 2017 3:45 pm
Re: HTML-table as variable in HTML-mail?
Yeah the Run Command app is great for parsing text files into private data. I use these on the Mac in the zsh shell all the time
to read all the text
to read just the first line
to read everything after the first line
to read lines that contain the string 'keyword'
to read all the text
Code: Select all
cat %%InputFilePath%%
Code: Select all
head -1 %%InputFilePath%%
Code: Select all
tail -n +2 "%%InputFilePath%%"
Code: Select all
awk '/keyword/{print}' "%%InputFilePath%%"