Sending SMTP mail

Question ID : 187
Created on 2012-01-03 at 2:39 PM
Author : Veryant Support [support@veryant.com]

Online URL : http://support.veryant.com/support/phpkb/question.php?ID=187



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).



Back to Original Question