REQUIREMENTS

  • The IMAP id of the Gmail email to be open
  • Lotus notes needs to be installed in the client machine and you need to know the path of the executable
  • Basic knowledge of Java Programming

CODE

The program consist of two main classes

DBService – this class creates a connection to the Lotus Notes database using the Domingo API. Il contains a method getDDocuments(String gmailImapID) that searches the Lotus Notes database for the Lotus Notes document using the gmailIMapID.

 DBService class

package it.myti.lotusNotes.integrator.db;

import java.util.Iterator;
import de.bea.domingo.DBaseItem;
import de.bea.domingo.DDatabase;
import de.bea.domingo.DDocument;
import de.bea.domingo.DNotesException;
import de.bea.domingo.DNotesFactory;
import de.bea.domingo.DSession;

public class DBService  {
	private DDatabase database = null;	
	private DNotesFactory factory = DNotesFactory.getInstance();
	private DSession session = factory.getSession();
	
	public DBService() {
		try {			
			database = session.getMailDatabase();
		} catch (DNotesException e) {
			e.printStackTrace();
		}
	}
	
	public DDatabase getDatabase() {
		return database;
	}
	
    public DDocument getDDocument(String gmailImapID) {
    	DDocument document =  null;   	
    	if( database != null) {
    		Iterator docs =  database.search("$MessageID = \"" + gmailImapID + "\"") ;
    		
    		while( docs.hasNext()) {
    			document = (DDocument)docs.next(); 
    			break;
    	     }
		 }else {
			System.out.println("Error: cannot connect to lotus database"); 
		 }
    	
    	return document;
	}
    
    
    

DomingoMain – This class contains the Java main method. In this class, I invoked the method getDDocument(gmailImapID) on the DBService db object to get the Lotus Notes document passing the gmailIMapID of the Lotus Notes to be opened. Then I launched the Lotus Notes program using the method Runtime.getRuntime().exec(execString). Where

execString = Lotus Notes executable path + space + Lotus Notes Universal Unique ID

as can be seen in the screenshot below.

DomingoMain class

package it.myti.lotusNotes.integrator.core;

import java.io.IOException;
import de.bea.domingo.DDocument;
import it.myti.lotusNotes.integrator.db.DBService;

public class DomingoMain  {

	public static void main(String[] args) {
		//search by Gmail IMAP ID
		String gmailImapID= ""; 
		
		//Path to the Lotus Notes executable
		String path =  "C:\\Program Files\\IBM\\Lotus\\Notes\\notes.exe";
		DBService db =  new DBService(); 
		DDocument document = db.getDDocument(gmailImapID);
		String exeString = path + " " + document.getURL();
		
		if(document != null ) {
		   try {
				Runtime.getRuntime().exec( exeString );
		    } catch (IOException e) {
				e.printStackTrace();
		    }
		}else {
			System.out.println("Error: Lotus Notes document non found.");
		}
	    
	 	
	}
}

RESULT