CIB JCoMod technical documentation (EN)

5. Quick start

5.9. JCoMod Wrapper example for CIB mail: Job for (Batch) dispatch of a document via CIB mail (only Win32/MAPI)

import com.cib.comod.jobs.ICibMailJob;
import com.cib.comod.jobs.JCibMailJob;

public boolean doMailJob()
{
    JCibMailJob t_Job = new JCibMailJob(); 
    t_Job.initialize(); 
    if (!t_Job.isInitialized())
    {
        System.out.println("Fehler beim Initialisieren des JCibMailJob");
        //t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0)
        return false;
    };
    //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSEKEY, "..."); 
    //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSECOMPANY, "..."); 
    // Folgende Zustände können abgefragt werden: 
    // MailNone, MailActive, MailDeactivated 
    String t_MailAvailable =
              (String)t_Job.getProperty(ICibMailJob.PROPERTY_MAILAVAILABLE);

    // Den Maildialog benutzen, kein Batchbetrieb! 
    t_Job.setProperty(ICibMailJob.PROPERTY_MAILDIALOG, new Boolean(true));

    // Mailsystem ist möglicherweise nicht aktiv, es soll aber trotzdem 
    // - wenn möglich - Email genutzt werden 
    t_Job.setProperty(ICibMailJob.PROPERTY_MAILLOGONDIALOG,new Boolean(true));

    // Email-Adresse, Betreff und Attachments einstellen
    t_Job.setProperty(ICibMailJob.PROPERTY_MAILRECIPIENT ,"mustermann@musterserver.de");
    t_Job.setProperty(ICibMailJob.PROPERTY_MAILSUBJECT ,"Sehr wichtig!");
    t_Job.setProperty(ICibMailJob.PROPERTY_MAILATTACHMENTS ,"c:\temp\wichtig.rtf");

      //Job ausführen
      t_Job.execute();

    //Fehlerbehandlung
    int t_Error = 
        ((Integer)t_Job.getProperty(ICibMailJob.PROPERTY_ERROR)).intValue();
    if (t_Error != 0)
    {
        // Fehler beim Ausführen des Jobs
        String t_Errortext = (String)
            t_Job.getProperty(ICibMailJob.PROPERTY_ERRORTEXT);
        System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext);
        //t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0)
        return false;
    }
    //t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0)
    return true;
}