Sending email both text/plain and text/html content type (RESOLVED)

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
dvanoni
Posts: 32
Joined: Wed Dec 02, 2015 3:47 am
Location: Chiasso - Switzerland

Sending email both text/plain and text/html content type (RESOLVED)

Post by dvanoni » Tue Nov 05, 2019 7:32 pm

Hi all,

I need to send emails with text/html content type. I can do that using Lansa Integrator with SMTPMailService and everything works fine.
Now I need to include also the text/plain content type in the text/html email because some spam filter rejects email with only the text/html content type (for example SpamAssassin -https://spamassassin.apache.org/- assigns a lower score to these email due to MIME_HTML_ONLY rule).

Is it possible to create an email with both content types in Lansa? The source code of the email should be something like this (in bold the part to add):

Date: Mon, 4 Nov 2019 16:03:35 +0100 (CET)
From: Test email <xxx@sss.com>
To: yyy@sss.com>
Message-ID: <-818934553.137.1572879815524.JavaMail.dcwpgmlib@xxx.xx>
Subject:
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_136_1606614110.1572879815523"

------=_Part_136_1606614110.1572879815523
Content-Type: text/html;charset=iso-8859-1
Content-Transfer-Encoding: 7bit

<h2>Test email</h2>
<p>&nbsp;</p>
<p><strong>Test emailt</strong></p>
<p>Test email</p>
<p>&nbsp;</p>
------=_Part_136_1606614110.1572879815523--

------=_Part_136_1606614110.1572879815523
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Test email

Test email

------=_Part_136_1606614110.1572879815523--


Thanks
Last edited by dvanoni on Wed Nov 13, 2019 9:11 pm, edited 1 time in total.

pkoopmanpk
Posts: 24
Joined: Wed Apr 26, 2017 7:12 pm

Re: Sending email both text/plain and text/html content type

Post by pkoopmanpk » Wed Nov 13, 2019 7:19 pm

You should use the commands SET CONTENT(*HTML) and SET CONTENT(*PLAIN)

Code: Select all

#JSMXCMD := 'SET SERVER(' + #JSM_HST + ')'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

#JSMXCMD := 'SET PORT(' + #JSM_PRT + ')'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

#JSMXCMD := 'SET USER(' + #JSM_USER + ')'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

#JSMXCMD := 'SET PASSWORD(' + #JSM_PWD + ')'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

#JSMXCMD := 'SET FROM("' + #COM_OWNER_mJsmEscape( #JSM_FROM ) + '")'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

#JSMXCMD := 'SET TO(*LIST)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG #wl_to_list)

#JSMXCMD_U := 'SET SUBJECT("' + #COM_OWNER_mJsmEscape( #JSM_SUBJECT ) + '")'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD_U) To_Get(#JSMXSTS_U #JSMXMSG_U)

* -- SET BODY (html) --
#JSMXCMD := 'SET CONTENT(*HTML) BODY() SERVICE_LIST(wl_html_list)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG #wl_html_list)

* -- SET BODY (plain/text) --
#JSMXCMD := 'SET CONTENT(*PLAIN) BODY() SERVICE_LIST(wl_text_list)'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG #wl_text_list)

#JSMXCMD := 'SEND'
Use Builtin(JSMX_COMMAND) With_Args(#JSMXHDLE1 #JSMXCMD) To_Get(#JSMXSTS #JSMXMSG)

dvanoni
Posts: 32
Joined: Wed Dec 02, 2015 3:47 am
Location: Chiasso - Switzerland

Re: Sending email both text/plain and text/html content type

Post by dvanoni » Wed Nov 13, 2019 9:10 pm

Thanks! It works!

Post Reply