Page 1 of 1

Integrator SMTPMailService Rich Emails

Posted: Wed Oct 25, 2017 4:56 am
by jyoung
I'm starting to do some research on how to send a rich html based email from Integrator.
The emails I have sent before have been simple text / one liners with attachments.

This email will be rich with different text formats, "call to action" indicators and dynamic data/content.

I am trying to figure out the best way to do this. From here https://www.lansa.com/support/tips/t0320.htm I could put all the html in a working list and go that route.

This doc http://docs.lansa.com/14/en/lansa093/in ... 7_2225.htm states that I could use a file and the example uses a "emailtext.txt" file.

A couple questions immediately come up:
  1. Where should this file reside on the server?
  2. Is this file a template, meaning it supports variable substitution, or is it just a static content file? If its just static content, that likely eliminates this option.
Thanks,
Joe

Re: Integrator SMTPMailService Rich Emails

Posted: Fri Oct 27, 2017 1:00 pm
by alick
Hi,

1. Using file approach, the file must reside on the same server as the JSM server, the file content is static.

You can use an absolute path to any location on the server, or a path relative to the JSM instance path.

SET CONTENT(*HMTL) BODY(/folder/file.html) ENCODING(UTF-8)

or

SEND CONTENT(*HMTL) BODY(/folder/file.html) ENCODING(UTF-8)


2. Using working list, create the working list in the LANSA function.

SET CONTENT(*HMTL) #WRKLST

or

SEND CONTENT(*HMTL) #WRKLST

#WRKLST can be a single column/field, each list entry is a line.

#WRKLST can have 2 column/fields, each list entry is a line, the second column is the newline control.

DEFINE FIELD(#TXT) TYPE(*CHAR) LENGTH(80)
DEFINE FIELD(#CNTL) TYPE(*CHAR) LENGTH(2)
DEF_LIST NAME(#MESSAGE) FIELDS((#TXT) (#CNTL)) TYPE(*WORKING)

CHANGE FIELD(#CNTL) TO(*BLANK)
CHANGE FIELD(#TXT) TO('''<B>This is the third line of text</B>''')
ADD_ENTRY TO_LIST(#MESSAGE)

Re: Integrator SMTPMailService Rich Emails

Posted: Mon Oct 30, 2017 2:11 pm
by BrendanB
Joe,

you can use a file as a template by doing:

Code: Select all

Define Field(#EmailText) Type(*CHAR) Length(1000) Input_Atr(LC)

Def_List Name(#EmailBody) Fields(#EmailText) Type(*WORKING) Entrys(*MAX)

Use Builtin(TRANSFORM_FILE) With_Args(#EmailBody #TemplateName T) To_Get(#FILE_RETC)
#TemplateName is the name of the file (full path to the file).

if you have setup something you can scan for, then you can do substitutions. (eg:

Code: Select all

Selectlist Named( #EmailBody)

#EmailText.ReplaceAll('%Name%' #FullName)

Endselect
and then use something like:

Code: Select all

#jsmxcmd := 'SEND SUBJECT(' + #Subject + ') CONTENT(*HTML)'
Use Builtin(JSMX_COMMAND) With_Args(#currentJSMhandle #jsmxcmd) To_Get(#jsmxsts #jsmxmsg #EmailBody)
when you send.