• Post Reply Bookmark Topic Watch Topic
  • New Topic


Jamie Haynes
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request is to receive e-mail ( via Lotus notes database), I get a handle to it in java application, and get the value from the BODY field. The Vector vecBody = ndoc.getItemValue("Body"); line returns a vector with the entire value of the email in the first element of the vector ( note the e-mail has multiple lines - it is actually text that represents a PO).

Now, I simply want to write one line at a time to a relational database table. Yes, this sounds strange, but one record will be the first line of PO e-mail, another record will be second line of PO e-mail, etc. Hey, I didn't design it, just trying to do it.

I am new to java... I have the below code that gets me all the way to having the text of e-mail in vector, but from there I don't know exactly what to do. Java experts told me to use BufferedReader... but it looks like they only take in actual file names. I don't have file, I have a vector full of text with carriage returns in it.

Any idea how I should do this? Any comments appreciated. Thank you.
- jamie

package EmailParser;

import java.io.*;
import java.util.Vector;
import lotus.domino.*;

//import com.util.AppProperties;
//import com.util.ApplicationInitializationException;
//import empSyncNotify.ProcessController;

* @author haynesj
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class EmailParser extends AgentBase{

* Developer: Jamie Haynes
* Date:9/29/2005
* Purpose:This Java program will be called by an rpg program.
* Java program will get a handle to specific, unprocessed
* e-mails in the target notes db using the 'EMailsNewView' view.
* Program shall loop through all documents.
* If a document does not have the text �Shipping Information:� within the
* first four lines of �Body� field, then Program shall create text field
* named �Processed� and set it to �YES� and save the document and loop to next
* document in collection.
* Program shall parse through �Body� field of each e-mail containing the
* text �Shipping Information:� within the first four lines and
*1.write one record only containing the document�s �From� field while trimming
*all �<� and �>� and blank spaces from beginning and end of string to PO821F
*2.write one record for every line in document�s �Body� field to PO821F while
*trimming all spaces from beginning and end of line.
*Program shall call RPG program ( PO821R ).
*On successful return of RPG program, program shall make the e-mail as processed by
*creating a text field named �Processed� and setting its value to �YES�.
*On unsuccessful return of RPG program, program shall simply loop to next available
*e-mail in collection.
*Program shall continue looping through all documents until end of collection while
*logging update and error information for each e-mail to emailparserlog.text.

* References:process\process.nsf on AMADB01 (notes database)
* Work Request:2005311
private final String NOTES_TEST_SERVER_IP = "XXXXX";
private final String NOTES_LIVE_SERVER_IP = "XXXXX";
private final String PROCESS_REP_ID_DZIN = "XXXXX";
private final String NOTES_USER = "XXXX";
private final String NOTES_WORD = "XXXXX";

private Session nsess;
private boolean bIsTestRun;
private Database ndbProcessDB ; //Process database...

// Constructor
public EmailParser(){};

public static void main(String[] args) {
System.out.println( "Start program from java application..." );

EmailParser controller = new EmailParser();

// Initialize logging data...
// controller.init();
controller.bIsTestRun = true;
// Set the nsess session property in setSession if we don't already have it...
// get Process db and assign to ndbProcessDB.
// Return collection of notesdocuments to process.
DocumentCollection nClxn = controller.getUnProcessedDocs();
if ( nClxn.getCount() > 0){
System.out.println("Total documents retrieved = " + nClxn.getCount() );
// Loop through documents...
Document ndoc = nClxn.getFirstDocument();
int ndocCtr = 1; // count number of documents in entire collection as we loop through them.
int POCtr = 0; // count unprocessed documents that are considered POs.
int nonPOCtr = 0; // count unprocessed documents that are NOT considered POs.

while (ndoc != null) {
System.out.println("ndocCtr = " + ndocCtr );

// get contents of Body field...
Vector vecBody = ndoc.getItemValue("Body");
if (controller.isPO(vecBody)){
int x;
System.out.println("Controller says isPO = true.");
// Now write this docment to AS/400 one line at a time
// and then call rpg program to process...

BufferedReader d = new BufferedReader(new InputStreamReader(vecBody));

ndoc.replaceItemValue( "Processed", "YES" );
System.out.println("getting next ndoc...");
ndoc = nClxn.getNextDocument();
ndocCtr++ ;
}//close while
ndoc = null;
System.out.println("POs = " + POCtr );
System.out.println("NONPOs = " + nonPOCtr );
}// end if

nClxn = null;

}catch (NotesException ne){
//}catch (IOException io){
}finally {
System.out.println("The End.");

[ October 12, 2005: Message edited by: Jamie Haynes ]
Jesper de Jong
Java Cowboy
Posts: 15715
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what exactly does the vector contain? Does it contain only one element, a String, which contains the entire PO?

You can use java.io.StringReader to read from a String, and you can wrap the StringReader with a BufferedReader to read it line by line.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!