Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

This is a bunch of tips and techniques related to Oracle PL/SQL and Forms.

Publicité

Send email with html body and local file attachments

Purpose

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.


javamail

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

     Sendmail.java     SendMessageException.java.java



The implementation class of the Bean Item

     oracle.forms.fd.SendMail


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

e.g. :

 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

 permission java.security.AllPermission;


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

Publicité
Retour à l'accueil
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article
S
16 error
Répondre