There is an example that uses SMTP email in our sample programs, %ISCOBOL%sampleis-javaiscobol-uses-java-objectothersmailSENDMAIL.cbl
This sample uses the JavaMail API to send SMTP emails from a COBOL program, first connecting to the SMTP, authenticating the username and password using a CLASS-ID called MYAUTHENTICATOR (the MYAUTHENTICATOR.cbl program provided in the sample folder), and then assembling and sending the email with the information given.
It requires the javax.mail.jar file downloaded from the
here.
If you use Java 11, you will also need to download javax.activation-1.2.0.jar from
here.
These files will need to be in the CLASSPATH.
The easiest way to do that is to put the jars in the %ISCOBOL%/jars folder.
Since the use of Veryant's samples is open, you can easily send emails from your application by modifying the SENDMAIL.cbl program to accept inputs for the smtp information (host, port, user, password, and security type), and for the mail contents (from, to, cc, bcc, reply to, subject, text in html or plain text, and attachments).
Article ID: 187
Created: January 3, 2012
Last Updated: July 28, 2021
Author: Support KB Author
Online URL: https://support.veryant.com/phpkb/article.php?id=187