Here is a Java bean that allows to send emails with html body and attachments.
It is a modified version of the Oracle Forms Demo's javamail bean.
The javamail Oracle Forms Demo allows to send emails with attachments located on the server side.
This one is executed on the local machine, can send emails with html body and attachments from the local machine.
It needs the JavaMail(TM) API 1.4 release, so it can't run under JInitiator. You need to run the Sun Java Plug-in.
The Java code
The implementation class of the Bean Item
The methods you can call
- Set the SMTP authentication
Set_Custom_Property('BLOCK.ITEM', 1, 'SET_MAIL_AUTHENTICATION', 'username,password');
If you provide authentication, this method must called first.
- Set the mail parts
Set_Custom_Property('BLOCK.ITEM', 1, 'SET_MAIL_INFOS', 'infos');
where infos are:
smtp addess | From | To | Subject | Body | attachment
LC$Infos := :MAIL.SMTP_SERVER || '|'
|| :MAIL.FROM || '|'
|| :MAIL.TO || '|'
|| :MAIL.SUBJECT || '|'
|| :MAIL.BODY || '|'
|| :MAIL.ATTACHMENTS ;
Set_Custom_Property( 'CONTROL.MAIL', 1, 'SET_MAIL_INFOS', LC$Infos ) ;
Each attached file in the list is separated with a coma.
Java security indication:
You have to update the .../Java/jre1.X.XX/lib/security/java.policy file to grant security permission
This bean need the mail.jar and activation.jar files wich are part of the JavaMail(TM) API 1.4 release
(these 2 jar files are provided with the zip file with this article)
The sample dialog
. Download the javamail.zip file
. Unzip the file
. copy the mail.jar, activation.jar and SendMail.jar file in the <ORACLE_HOME>/forms/java directory
. Edit your /forms/server/formsweb.cfg file to add these 3 jar files
. Open the javamail.fmb module (Oracle Forms 9.0.2)
. Compile all and run the module