First, note the following:
To obtain the corresponding database, the database path must be relative to the mtdata/mtstore. nsf file in the data directory.
If you want to operate the user's email database songlb, you must specify the mail/songlb. nsf file directory.
The data structure and meaning of mtcstore. nsf are as follows:
/**
* Database interface used to read mtcstore. nsf data
*
* @ Author songlb
*
* ----- Original structure: ---- 0dispstat ------ [4.0] 1disptm ------ [15:51:28 ze8]
* 2mta ------ [ultrapower/ultranms] 3nextmta ------ ['z] 4prevmta ------ ['z]
* 5nodelrea ------ ['z] 6msgtm ------ [15:51:23 ze8]
* 7ms GSZ ------ [1544.0] 8unqmsgid ------ [of46892529: 11e0d26d on48257070: 002b2802]
* 9inmsgid ------ [OFFC2465D0.7ED6D035-ON4825706F.0029D02C-4825706F.002A36F1]
* 10outmsgid ------ [OFFC2465D0.7ED6D035-ON4825706F.0029D02C-4825706F.002A36F1]
* 11inorg ------ [mail router] 12outorg ------ [mail router]
* 13inrcp ------ [wanghp/ultranms @ changeself]
* 14outrcp ------ [wanghp/ultranms @ changeself] 15subj ------ [test]
* 16msgtype ------ [8.0] 17form ------ [($ mtresp)] 18numentries ------ [1.0]
* 19earliestmsgtm ------ [15:51:23 ze8] 20latestmsgtm ------ [
* 15:51:23 ze8] 21 $ updatedby ------ [CN = ultrapower/o = ultranms]
*
* ====== Usage structure: ===== [Sender]: outorg [Receiver er]: outrcp [title]: subj
* [Reason]: nodelrea [Status]: dispstat [time]: latestmsgtm [msgid]: unqmsgid
*
*
*
* Where: dispstat: 1 = unknown 2 = inqueue 4 = delivered 8 = delivery_failed
*
* 16 = transferred
*
* 32 = transfer_failed 64 = group_expanded 1073741824 = deleted
*
* Msgtype: 1 = unknown 2 = memo 4 = deliveryreport 8 = nondeliveryreport
* 16 = returnreceept 32 = phonemessage 64 = tracereport 128 = notice
*/
The following is a monitoring program that runs after I start the MTC service. However, there is no environment to ensure the correctness of the program, but the principle can be used for reference.
Public class tracemaildao {
Private Static string user = "songlb ";
Private Static string passwds = "123456789 ";
Static logger log = logger. getlogger ("tracemaildao ");
Private hashmap persons = new hashmap (); // set of users to be tracked
/**
* The path of the database is relative to mtdata/mtstore. nsf in the data directory.
*
* @ Param accessdb
* @ Return
* @ Throws notesexception
*/
Public static database getdb (string accessdb) throws notesexception {
Lotus. Domino. Session S = Lotus. Domino. notesfactory. createsession (
Jdbcconstants. dominohost, user, passwd );
Log.info ("Domino server host name:" + S. getservername () + "version :"
+ S. getnotesversion ());
Lotus. Domino. Database DB = S. getdatabase (null, accessdb );
If (! DB. isopen ()){
DB. open ();
}
// Print the database title and size
// System. Out. println ("title:" + dB. gettitle () + "Size:" +
// DB. getsize ());
Return dB;
}
/**
* The data from the alluser table of the mcstore. nsf database is used to filter the bounce messages of the Daily Mail router system. 1. The program only obtains the Bounce Message of the current day every day.
* 2. emails of the person who obtained the tracking
*/
Public list getmtcdatas (){
Arraylist ls = new arraylist ();
Try {
Database DB = tracemaildao. getdb (jdbcconstants. DB); // obtain the database
View view = (View) dB. getview (jdbcconstants. dbview); // obtain the mail view you want
Document Doc = view. getfirstdocument ();
Vector columnnames = view. getcolumns (); // obtain all column names
Nsfmail entity = NULL;
Boolean flag = false;
While (Doc! = NULL ){
Entity = new nsfmail ();
Vector values = Doc. getcolumnvalues ();
String TMP = NULL;
String tmpstr = "";
For (Int J = 0; j <columnnames. Size (); j ++ ){
String columnname = (string) columnnames. elementat (j)
. Tostring (). Trim ();
If (columnname. Length ()! = 0 ){
// Log.info (values. Get (j). getclass ());
// Viewcolumn column = (viewcolumn)
// Columnnames. elementat (j );
If (columnname. Equals ("sender ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
/**
* // 1. The system returns the email.
*/
If (TMP. indexof ("mail Router")>-1 ){
} Else {
// Flag = false;
// Break;
}
Entity. setsender (TMP );
} Else {
TMP = (string) values. Get (j );
}
} Else if (columnname. Equals ("receiver ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
} Else {
TMP = (string) values. Get (j );
}
/**
* // 2. Determine whether the user is to be tracked
*/
If (persons. containskey (TMP )){
} Else {
// Flag = false;
// Break;
}
Entity. setreceiver (TMP );
} Else if (columnname. Equals ("title ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
} Else {
TMP = (string) values. Get (j );
}
Entity. settitle (TMP );
} Else if (columnname. Equals ("reason ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
} Else {
TMP = (string) values. Get (j );
}
Entity. setreason (TMP );
} Else if (columnname. Equals ("status ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
} Else {
TMP = string. valueof (values. Get (j); // a single value belongs to the double type.
}
/**
* 3. Check whether the email fails to be delivered or the email fails to be delivered.
*/
If (TMP. indexof (jdbcconstants. delivery_failed)>-1
| TMP
. Indexof (jdbcconstants. transfer_failed)>-1 ){
} Else {
Flag = false;
// Break;
}
Entity. setstatus (TMP );
} Else if (columnname. Equals ("time ")){
Tmpstr = string. valueof (datetime) values. Get (j ));
Tmpstr = tmpstr. substring (0, 19 );
/**
* // 4. Determine whether the email is returned today.
*/
String nowtime = dateutil. timeslong2date (new date ()
. Gettime ());
String [] Rt = nowtime. Split ("");
Nowtime = RT [0] + "00:00:00 ";
Long T1 = dateutil. stringtodate (nowtime). gettime ();
// Log.info ("T1:" + T1 );
// Log.info ("TD1:" + dateutil. stringtodate (TMP ));
Nowtime = RT [0] + "23:59:59 ";
Long T2 = dateutil. stringtodate (nowtime). gettime ();
Long T3 = (dateutil. stringtodate (tmpstr). gettime ();
If (T3> = T1 & T3 <= t2 ){
} Else {
// Flag = false;
// Break;
}
Entity. settime (T3 );
} Else if (columnname. Equals ("msgid ")){
If (values. Get (j) instanceof vector ){
TMP = (vector) values. Get (j). tostring ();
} Else {
TMP = (string) values. Get (j );
}
Entity. setmsgid (TMP );
}
}
}
If (FLAG ){
Ls. Add (entity );
Log.info ("888888 ");
}
Doc = view. getnextdocument (DOC );
//}
System. Out. println ("");
}
} Catch (Lotus. Domino. notesexception e ){
E. printstacktrace ();
} Catch (exception ex ){
Ex. printstacktrace ();
}
Return ls;
}
Public static void main (string [] ARGs ){
Tracemaildao Dao = new tracemaildao ();
Arraylist ls = (arraylist) Dao. getmtcdatas ();
For (INT I = 0; I <ls. Size (); I ++ ){
Log.info (LS. Get (I). tostring ());
}
}
}