-------------------- cut here ------------------------------------------------ $! Command procedure to automatically retrieve mail messages and insert $! them into a VAX Notes conference. A VMS account should be set up $! to run this procedure and to receive Internet mail. This account $! must have Moderator privilege to all VAXNotes conferences that it $! feeds. This one command procedure can handle multiple mailing lists. $! $! IMPORTANT: The account that this command procedure is executed from $! *MUST* already be set up with all Notes conferences in its VAX $! Notes Notebook. It must also have moderator privilege for all $! conferences. $! $! Basic idea taken from a command procedure posted to Info-VAX. $! $! 7-27-90 Brian Shamblin, Mayo Foundation (Internet: shamblin@mayo.edu) $! $! Please send all bug reports and requests to the above address. $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $ on error then goto error $! $! S I T E S P E C I F I C I N F O R M A T I O N $! $! The 'notes_moderator' will receive a mail message if this procedure $! has some problem. This should NOT be the account that is running $! this procedure; it SHOULD be a real person who is responsible for $! this software. $! $ notes_moderator = "Shamblin" $! $! 'queue_name' is the name of the queue to resubmit this job to. $! $ queue_name = "yoda$batch" $! $! 'resubmit_time' is the delta time for re-submitting this job. $! +1:00:00 = 1 hour. $! $ resubmit_time = "+1:00:00" $! $! The following two lists are for the notes conferences. The list $! 'notes_from_list' must match part of the VMS Mail "FROM:" line from $! the sender of the message (i.e. InfoVAX comes to our site as $! "RELAY-INFO-VAX@crvax.sri.com", so we use "INFO-VAX" for this value). $! The list 'notes_conf_list' is the corresponding VAXNotes conference $! name. The list elements for the 2 lists must correspond (i.e. $! element 1 of the 'notes_conf_list' is the notes conference for element $! 1 of the 'notes_from_list'. $! Each list is a "/"-separated list, with no "/" at the front or the $! end of the list. If the list contains only one element, then do $! not insert any "/". $! $! All entries in 'notes_from_list' should be in uppercase, unless the $! string to match is within quotes in the "From" record. If within $! quotes, then the case should match (i.e.: $! $! From: FERMAT::"xpert-mailer@expo.lcs.mit.edu" -> /xpert/ $! From: FERMAT::"RELAY-INFO-VAX@crvax.sri.com" -> /INFO-VAX/ $! From: FERMAT::NUTWORKS -> /NUTWORKS/ $! $ notes_from_list = "INFO-VAX/LANWORKS/NUTWORKS/risks/xpert/rdg" $ notes_conf_list = "InfoVAX/LANWORKS/JOKES/RISKS/XPERT/HOMEBREW" $! $! End site-specific information $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $! $! Buffer the incoming mail, so that a new incoming message doesn't hose $! the whole operation. Copy all new messages to the mail folder. $! $ define/user sys$output NL: $ mail select newmail move/all mail yes $! $! Loop, read each message and process it. $loop: $! $ define/user sys$output NL: $ on error then goto no_more_messages $ mail read mail 1 extract notes-mail.txt delete $! $! If no file exists, then no more mail messages to process $! $ open/error=no_more_messages/read infile notes-mail.txt $! $ subject = "" ! default subject $! $! Scan the header of the mail message for the From: and Subject: lines. $! The From: line will determine which conference to stuff this message $! in, and the Subject: line determines the subject for Notes topic. $! $scan_header: $ read/end=end_of_subject infile record $ if (f$extract(0, 5, record) .eqs. "From:") $ then $ gosub get_conference_name ! set 'notes_conference_name' $! $! If no conference name was set, then we found no match in the $! list. A mail message was sent, and cleanup performed. $! $ if (notes_conference_name .eqs. "") then goto loop $! $ goto scan_header ! process next line of header $ endif $! $ if (f$extract(0, 5, record) .eqs. "Subj:") .or. - (f$extract(0, 8, record) .eqs. "Subject:") $ then $ subject = record - "Subj:" - "Subject:" $ subject = f$edit(subject,"trim") ! remove leading spaces $ read infile record ! one blank line follows subject record $ goto end_of_header ! done with header stuff $ endif $! $ goto scan_header $! $! $end_of_header: $! $! put the rest of the message into the note (skip header info). $! $ open/write outfile new-note.txt $! $extract_loop: $ read/end=done_extract infile record $ write outfile record $ goto extract_loop $! $done_extract: $ close infile $ close outfile $ on error then goto error $! $! If this is a reply to a note (contains RE: or Re: at the beginning $! of the subject), then see if we can find the original note and post $! this as the reply to it. If we can't find the original note, or it $! is not a reply, then post it as a new topic. $! $! Create a file to execute that contains the commands to run notes, $! enable moderator, write the note (and subject), and exit. Written $! "on-the-fly" since it needs embedded symbols for VAXNotes commands. $! $ open/write note_file writenotes.com $ wf := write note_file $! $! Is this a reply to a previous message (message begins with re: of $! some case). $! $ check_reply = f$extract(0, 4, subject) $ if (check_reply .eqs. "Re: ") .or. - (check_reply .eqs. "RE: ") .or. - (check_reply .eqs. "re: ") $ then $ re_subject = subject - check_reply ! original topic $ gosub write_file_for_reply $ else $ gosub write_file_for_new_topic $ endif $! $ close note_file $ @writenotes $! $ delete/nolog notes-mail.txt;* ! this must be here for loop to terminate $! $ goto loop $! $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $! $! Get_conference_name determines the conference name from the sender $! of the message (in the "From:" line). When this subroutine is called, $! the symbol 'record' has the entire "From:" line, including the sender. $! The list 'notes_from_list' is scanned to see if we have a match within $! 'record'. If we have a match, then set 'notes_conference_name' to $! the corresponding element in 'notes_conf_list'. If no match, then $! set 'notes_conference_name' to "", clean up, and send a message to the $! "moderator". $! $get_conference_name: $ temp_record = f$edit(record,"upcase,trim") ! clean it up $ notes_conference_name = "" ! clear out any old values $ element_number = 0 ! counter for extracting from list $get_conference_name_loop: $ temp_name = f$element(element_number, "/", notes_from_list) $ if (temp_name .eqs. "/") ! reached end of list with no match $ then $ close infile ! close the message, and send it to moderator $ mail/subject="No valid conference name found" - notes-mail.txt 'notes_moderator' $ delete/nolog notes-mail.txt;* ! clean up for next pass $ return $ endif $! $ if (f$locate(temp_name, temp_record) .ne. f$length(temp_record)) $ then ! found match $ notes_conference_name = f$element(element_number, "/", notes_conf_list) $ return $ endif $! This element didn't match, go check the next element $ element_number = element_number + 1 $ goto get_conference_name_loop $! $! return from subroutine is above... $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $! $write_file_for_reply: $ gosub open_notes_file ! run notes, open conference $! See if a topic already exists for this reply $ wf "directory/title=""''re_subject'""/output=title.out" $ wf "close" $ wf "exit" ! terminate notes $ wf "$ exit" $! $! Close the command file, and execute it. Find out if we got the $! correct topic (output file exists). $! $ close note_file $ @writenotes $! $! Open the output file. If the file doesn't exist, then there was no $! match for the RE:, so post it as a new note. The output file has a $! bunch of header information in it, followed by the matching topic(s). $! Use the last topic as the one to post the reply to. $! $ open/read/error=write_new_note note-list title.out $topic_loop: ! loop until last record $ read/end=last_topic note-list record $ goto topic_loop $! $last_topic: $ close note-list $ delete title.out;* ! delete here so next loop works correctly $! $! Record format is: topic# author date replies title $! We just want the topic # $! $ topic_num = f$element(1, " ", f$edit(record,"compress")) $! $ open/write note_file writenotes.com ! re-open command file $! $! Now re-open notes, read the topic number that matched, and reply to it. $ gosub open_notes_file ! run notes, open conference $ wf " set moderator" $ wf "read ''topic_num'" $ wf "reply/title=""''subject'""/noconfirm/noedit new-note.txt" $ wf "set note/nowrite" $ wf "close" $ wf "exit" $ wf "$ exit" $ wf "$! $ return $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $write_new_note: ! no matching topic for reply $ open/write note_file writenotes.com ! re-open command file $ gosub write_file_for_new_topic ! same as new topic $ return $! $write_file_for_new_topic: $ gosub open_notes_file ! run notes, open conference $ wf "set moderator" $ wf "write/title=""''subject'""/noconfirm/noedit new-note.txt" $ wf "set note/nowrite" $ wf "close" $ wf "exit" $ wf "$ exit" $ return $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $open_notes_file: $ wf "$ define/user sys$output NL: $ wf "$ on error then continue" $ wf "$ notes" $ wf "open ''notes_conference_name'" $ return $! $! $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $error: $! $ on error then continue $! Report that we had an error $! $ mail/subject="Error with Mail to Notes conference ''notes_conference_name'" - notes-mail.txt 'notes_moderator' $ delete/nolog notes-mail.txt;* $ goto loop $! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $no_more_messages: $! $! No more mail messages (or none), so restart this job. But first $! determine the filename to submit (don't want the version number so $! that changes to this file will take affect with the next execution). $! $ filename = f$environment("procedure") $ submit_file = f$parse(filename,,,"name") $! $ submit/noprint/restart/after="''resubmit_time'"/queue='queue_name' - 'submit_file' $! $! do some cleanup... $ set noon $ delete writenotes.com;* $ delete new-note.txt;* $ purge/keep=10 'submit_file'.LOG ! purge the log file $! $ exit /* ---------- */