          SUBROUTINE (PASSER,O.BODY)
** Version# 118.0001[1] - 08/09/2012 - 09:28am - TSMITH - eclipse

*** Subroutine - EMAIL.SEND
*-------------------------------------------------------------------------*
*** User Display screen to send an email.  This routine fills out all
*** info such as email address, attachments, carbon copies, and
*** message.
*-------------------------------------------------------------------------*
*** Note on the To, Cc and Bcc email address inputs:
*** If the user uses our "Dist List" screen, a VM del'm list will be
*** passed back to this routine.  For this case, display "*Multi*" instead
*** of the full list of users.  However, the user can also send a multi
*** list by separating the address with either a comma or semicolon.
*-------------------------------------------------------------------------*
*** PASSER<1>  - Email Address
*** PASSER<2>  - Customer Number (e.g. Entity ID)
*** PASSER<3>  - Contact ID
*** PASSER<4>  - Recipient Name
*** PASSER<5>  - Subject
*** PASSER<6>  - Attachment path
*** PASSER<7>  - CC, Carbon Copies
*** PASSER<8>  - BCC, Blind Carbon Copies
*** PASSER<9>  - Flag to Send Attachment in Body
*** PASSER<10> - Flag that EMAIL.DATA.GET will send the email
***            - this is needed when sending attachments.
*** PASSER<11> - Flag to not call user for prompt
*** PASSER<12> - From Name (domain name will be system defined)
***            - If not passed will default to @LOGNAME
*** PASSER<13> - EMAIL.SEND cannot override attachment flag (PASSER<9>)
*** PASSER<14> - this will be the
***            - message keyed in by user if need to pass to other pgms.
*** PASSER<15> - User BCC address for copies of EMAIL (from SEC-57)
*** PASSER<16> - User BCC Subject Prefix (from SEC-58)
*** PASSER<17> - ATTACHMENT path/key reference e.g. HOLD.FILE:nnnnn
***            - for display in EMAIL.SEND options
*** PASSER<18> - ATTACHMENT type - .txt (default), .html, .doc, .xls
*** PASSER<19> - ATTACHMENT body type if sending attachment in Body
*** PASSER<20> - Sending email as a company HTML template
*** PASSER<21> - ATTACHMENT filename (optional, will default to
*** PASSER<22> - File name of template to be used for sent email
***            - USER.ID-###.TXT  where ### is a number starting at 100
*** PASSER<23> - Type of Email sent from activity trigger (html,text)
*** PASSER<24> - CC Recipient
*** PASSER<25> - BCC Recipient
*** O.BODY     - For passing Body - will be converted to vm for editing.
*-------------------------------------------------------------------------*
*** COMMON Variables:
***       PHANTOM.PROC and JAVA.PROC$ are read but not changed
*-------------------------------------------------------------------------*

          ERR.MSG = ''

          * If phantom or java, do not display error message
          IF PHANTOM.PROC OR JAVA.PROC$ THEN
             DISP.ERR = NO
          END ELSE
             DISP.ERR = YES
          END

          * check for auth
          UT.SEC3 22,AUTH.OK,,DISP.ERR
          IF NOT(AUTH.OK) THEN
             ERR.MSG = 'Outbound Email is not authorized!'
             RETURN
          END

          UT.OPEN.FILE 'VOC',VOCFILE,ERR.MSG,YES
          IF ERR.MSG THEN RETURN

          UT.OPEN.FILE 'CONTACT',CFILE,ERR.MSG,YES
          IF ERR.MSG THEN RETURN

          UT.OPEN.FILE 'MSG-OUT',MOUTFILE,ERR.MSG,YES
          IF ERR.MSG THEN RETURN

          GOSUB INIT
          IF ERR.MSG THEN RETURN

          SCREEN

RESTART:  *** restart here
          GOSUB SET.VARS
          GOSUB LOAD.HOTKEYS
*-------------------------------------------------------------------------*
IN.ADDR:  L.TYPE = 'T'

          IF DCOUNT(DIST.LIST<3>,VM) > 1 THEN
             PRINT @(16, 1):"*Multi*"      "L#53"
          END

          D.EMADDR = EMAIL.ADDR
IN.ADDR1: INP D.EMADDR,16,1,53,V_'S:VERF.EMAIL.ADDRESS'

          IF CHANGED OR (IS.EMAIL.ADDR.VALID = NO) THEN
             EMAIL.ADDR = D.EMADDR

             * If there is nothing in EMAIL.ADDR, it is legal although if
             * we try to validate it will be illegal.
             IF EMAIL.ADDR = '' THEN
                IS.EMAIL.ADDR.VALID = YES
             END ELSE
                CHK.ADDR = EMAIL.ADDR
                GOSUB CHK.EAFMT
                IS.EMAIL.ADDR.VALID = EAFMT

                * If the address(es) not legal, ring the bell and stay here
                * so the user can correct minor errors (e.g. typo).
                IF NOT(EAFMT) THEN
                   PRINT BELL:
                   GOTO IN.ADDR
                END
             END

             PASSER<1>    = EMAIL.ADDR
             DIST.LIST<3> = EMAIL.ADDR

             IF DCOUNT(DIST.LIST<3>,VM) > 1 THEN
                DIST.LIST<1> = ''
                DIST.LIST<2> = ''
             END

             E.LISTS(1) = LOWER(DIST.LIST)
             GOSUB DISPLAY
          END
          L.TYPE = ''

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.ADDR,IN.ADDR,IN.ADDR,IN.ADDR,IN.CC,IN.CC
*-------------------------------------------------------------------------*
IN.CC:    L.TYPE = 'C'

          IF DCOUNT(CC,VM) > 1 THEN
             PRINT @(16, 2):"*Multi*"      "L#53"
          END

          D.CC = CC
IN.CC1:   INP D.CC,16,2,53,V_'S:VERF.EMAIL.ADDRESS'

          IF CHANGED OR (IS.CC.VALID = NO) THEN
             CC       = D.CC

             * If there is nothing in CC, it is legal although if
             * we try to validate it will be illegal.
             IF CC = '' THEN
                IS.CC.VALID = YES
             END ELSE
                CHK.ADDR = CC
                GOSUB CHK.EAFMT
                IS.CC.VALID = EAFMT

                * If the address(es) not legal, ring the bell and stay here
                * so the user can correct minor errors (e.g. typo).
                IF NOT(EAFMT) THEN
                   PRINT BELL:
                   GOTO IN.CC
                END
             END

             PASSER<7>  = CC
             E.LIST     = ''
             E.LIST<3>  = CC
             E.LISTS(2) = LOWER(E.LIST)
          END
          L.TYPE = ''

          IF D.CC = '' THEN PASSER<7> = ''

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.CC,IN.CC,IN.ADDR,IN.CC,IN.BCC,IN.BCC
*-------------------------------------------------------------------------*
IN.BCC:   L.TYPE = 'B'

          IF DCOUNT(BCC,VM) > 1 THEN
             PRINT @(16, 3):"*Multi*"      "L#53"
          END

          D.BCC = BCC
IN.BCC1:  INP D.BCC,16,3,53,V_'S:VERF.EMAIL.ADDRESS'

          IF CHANGED OR (IS.BCC.VALID = NO) THEN
             BCC      = D.BCC

             * If there is nothing in BCC, it is legal although if
             * we try to validate it will be illegal.
             IF CC = '' THEN
                IS.BCC.VALID = YES
             END ELSE
                CHK.ADDR = BCC
                GOSUB CHK.EAFMT
                IS.BCC.VALID = EAFMT

                * If the address(es) not legal, ring the bell and stay here
                * so the user can correct minor errors (e.g. typo).
                IF NOT(EAFMT) THEN
                   PRINT BELL:
                   GOTO IN.BCC
                END
             END

             PASSER<8>  = BCC
             E.LIST     = ''
             E.LIST<3>  = BCC
             E.LISTS(3) = LOWER(E.LIST)
          END
          L.TYPE = ''

          IF D.BCC = '' THEN PASSER<8> = ''

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.BCC,IN.BCC,IN.CC,IN.BCC,IN.SUBJ,IN.SUBJ
*-------------------------------------------------------------------------*
IN.SUBJ:  INP SUBJECT,16,4,50
          PASSER<5> = SUBJECT

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.SUBJ,IN.SUBJ,IN.BCC,IN.SUBJ,IN.BODY,IN.BODY
*-------------------------------------------------------------------------*
IN.BODY:  INPWP BODY,1, 7,78,13,999,'0110'

          IF QUIT THEN GOTO FILEIT
          ON MOVE+1 GOTO IN.BODY,IN.BODY,IN.SUBJ,IN.BODY,IN.BODY,IN.BODY
*-------------------------------------------------------------------------*
INIT:     *** initialize necessary variables

          DIM E.LISTS(3)

          * used to convert FM before sending the email
          CRLF = CHAR(13):CHAR(10)

          REC.ID      = ''
          L.TYPE      = ''
          EMAIL.ADDR  = ''
          CC          = ''
          BCC         = ''

          * If using Eclipse Forms, we always send an attachment.  We
          * do not send the document in the body.
          IF USE.ECLIPSE.FORMS$ THEN
             PASSER<9>  = NO
             IF NOT(PASSER<28>) THEN
                PASSER<28> = "NEED_ID"
             END
          END

          * Since the addresses are '', they are valid
          IS.EMAIL.ADDR.VALID = YES
          IS.CC.VALID         = YES
          IS.BCC.VALID        = YES

          * Check EMAIL.SEND auth and eclipse email setup
          CHECK.KEY 'EMAIL.SEND',EMAIL.OK
          IF NOT(EMAIL.OK) THEN ERR.MSG = 'Not Authorized to send email'

          * If HTML type, then default to put in body of email, unless
          * user has previously set to NOT put in body (BODTYP = 0)
          IF OCONV(PASSER<23>,'MCU') = 'HTML' AND PASSER<9> # 0 THEN
             PASSER<9> = YES
          END

          RETURN
*-------------------------------------------------------------------------*
SET.VARS: *** set up all variables needed

          MAT E.LISTS  = ''
          EMAIL.ADDR   = ''
          SUBJECT      = ''
          BODY         = ''
          FROM.ADDR    = PASSER<12>
          CC           = ''
          BCC          = ''
          ATTACH.PATH  = ''
          RCL.ID       = ''
          CONTACT.LIST = ''
          EMAIL.ADDR   = PASSER<1,1>
          INIT.CN      = PASSER<2>
          CN           = INIT.CN
          INIT.CONT    = PASSER<3>
          CONT         = INIT.CONT
          DIST.LIST    = ''
          DIST.LIST<2> = PASSER<4>
          DIST.LIST<3> = PASSER<1>
          SUBJECT      = PASSER<5>
          CC           = PASSER<7>

          * Put CC in E.LISTS for passing to Distribution List Editor
          E.LIST       = ''
          E.LIST<3>    = CC
          E.LIST<2>    = PASSER<24>      ;* CC Recipient
          E.LISTS(2)   = LOWER(E.LIST)
          BCC          = PASSER<8>

          * Put BCC in E.LISTS for passing to Distribution List Editor
          E.LIST       = ''
          E.LIST<3>    = BCC
          E.LIST<2>    = PASSER<25>      ;* BCC Recipient
          E.LISTS(3)   = LOWER(E.LIST)
          BASATT       = PASSER<9>

          * If sending attachment in body, allow user to specify body
          * type of format; either TXT (default) or HTML
          BODY.TYPE = PASSER<19>

          IF NOT(BODY.TYPE) THEN BODY.TYPE = OCONV(PASSER<18>,'MCU')
          IF BODY.TYPE[1,1] = '.' THEN BODY.TYPE = BODY.TYPE[2,5]

          BODY = O.BODY
          CONVERT @FM TO @VM IN O.BODY

          READV CUST.NAME FROM CUSFILE,INIT.CN,1 ELSE CUST.NAME = ''
          READ CONT FROM CFILE,INIT.CONT ELSE CONT = ''

          CONTACT.NAME = CONT<1>
          IF TRIM(CONT<2>) THEN
             CONTACT.NAME = CONTACT.NAME:' ':CONT<2>
          END
          CONTACT.NAME = CONTACT.NAME:' ':CONT<3>

          RCL.IDS = 'T':VM:'C':VM:'B'

          * if a from address wasn't passed in, try to set one
          IF NOT(FROM.ADDR) THEN
             EMAIL.GET.FROM.ADDRESS FROM.ADDR
             PASSER<12> = FROM.ADDR
          END

          * If coming from a trigger and to name isn't set then do BCC
          BEGIN CASE
          CASE PASSER<23> AND PASSER<1>
             USE.INI.BCC = NO
          CASE PASSER<15> = '' ;* No BCC filled in
             USE.INI.BCC = YES
          CASE OTHERWISE
             USE.INI.BCC = NO
          END CASE

          IF USE.INI.BCC THEN
             READ UDATA FROM INIFILE,USER.ID ELSE UDATA = ''
             PASSER<15> = UDATA<57>           ;* BCC Email

             IF PASSER<16> = '' THEN
                PASSER<16> = UDATA<58>        ;* BCC Subject Prefix
             END
          END

          GOSUB DISPLAY

          RETURN
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO SEL.USER.DOC,PRTIT,EDIT.USER.DOC,EMOPTS,EDIT.LIST
*-------------------------------------------------------------------------*
CHK.EAFMT: *** Check Email Address format

          VPARAMS = 'FMT'
          VERF.EMAIL.ADDRESS ,,,CHK.ADDR,VPARAMS

          LOCATE 'FMTOK' IN VPARAMS<1> SETTING NADA THEN
             EAFMT = YES
          END ELSE
             EAFMT = NO
          END

          RETURN
*-------------------------------------------------------------------------*
EDIT.LIST: *** edit a distribution list

          IF NOT(L.TYPE) THEN RETURN

          IF NOT(DIST.LIST<3>) THEN DIST.LIST = ''
          LOCATE L.TYPE IN RCL.IDS<1> SETTING RPOS THEN
             RCL.ID = RCL.IDS<2,RPOS>
             BEGIN CASE
             CASE L.TYPE = 'T'
                E.LIST = DIST.LIST
             CASE L.TYPE = 'C'
                E.LIST = RAISE(E.LISTS(2))
             CASE L.TYPE = 'B'
                E.LIST = RAISE(E.LISTS(3))
             END CASE
          END
          EMAIL.DIST.EDIT E.LIST,CFILE,RCL.ID,L.TYPE

          BEGIN CASE
          CASE F12                          ;* No updates
             NULL
          CASE L.TYPE = 'T'                 ;* To Email Dist List
             DIST.LIST = E.LIST
             E.LISTS(1) = LOWER(E.LIST)
             IF DCOUNT(DIST.LIST<3>,VM) = 1 THEN
                EMAIL.ADDR = DIST.LIST<3,1>
             END
             IF DIST.LIST<3> = '' THEN EMAIL.ADDR = ''
          CASE L.TYPE = 'C'                 ;* Carbon Copy Dist List
             CC  = E.LIST<3>
             PASSER<7> = CC
             PASSER<24> = E.LIST<2>         ;* CC Recipient
             E.LISTS(2) = LOWER(E.LIST)
          CASE L.TYPE = 'B'                 ;* Blind Carbon Copy Dist List
             BCC = E.LIST<3>
             PASSER<8> = BCC
             PASSER<25> = E.LIST<2>         ;* BCC Recipient
             E.LISTS(3) = LOWER(E.LIST)
          END CASE

          GOSUB DISPLAY
          QUIT = NO

          IF L.TYPE = 'T' THEN
             RETURN TO IN.ADDR
          END

          RETURN
*-------------------------------------------------------------------------*
SEL.USER.DOC: *** gets the selected user comments

          UD.MSG = ''
          SEL.USER.DOC UD.MSG

          DCNT = DCOUNT(UD.MSG,@VM)
          FOR D = 1 TO DCNT
             BODY<1,-1> = UD.MSG<1,D>
          NEXT D
          GOSUB DISPLAY

          RETURN
*-------------------------------------------------------------------------*
EDIT.USER.DOC: *** allows you to create and edit user comments

          UD.MSG = ''
          USER.DOC.MAINT UD.MSG

          DCNT = DCOUNT(UD.MSG,@VM)
          FOR D = 1 TO DCNT
             BODY<1,-1> = UD.MSG<1,D>
          NEXT D
          GOSUB DISPLAY

          RETURN
*-------------------------------------------------------------------------*
PRTIT:    *** print email

          MSG.LN  = 1
          PG      = 0
          PG.LGTH = 53
          TITLE   = ''
          DRPT    = TITLE

          PRINTER.ON 80,TITLE,DOC.ID,
          GOSUB HEADER
          PRINT 'Message: '
          PRINT
          LN.CT = DCOUNT(BODY,@VM)
          FOR LN = 1 TO LN.CT
             IF (LN/PG) > PG.LGTH THEN
                PRINT
                PRINT SPACE(33):"** Continued **"
                PRINT CHAR(12):
                GOSUB HEADER
             END
             PRINT SPACE(10):BODY<1,LN>
          NEXT LN
          PRINTER.OFF DOC.ID

          RETURN
*-------------------------------------------------------------------------*
EMOPTS:   *** set up different options for email

          EMAIL.SEND.OPTS PASSER,DIST.LIST

          FROM.ADDR = PASSER<12>
          LOCATE L.TYPE IN RCL.IDS<1> SETTING RPOS THEN
             RCL.ID = RCL.IDS<2,RPOS>
          END ELSE
             RPOS = 1
          END

          IF DIST.LIST<3> THEN
             L.TYPE = 'T'
             GOTO EDIT.LIST
          END ELSE
             GOSUB DISPLAY
          END

          RETURN
*-------------------------------------------------------------------------*
HEADER:   *** print email header

          PG = PG + 1
          PRINT 'Email Address: ':EMAIL.ADDR
          PRINT 'Customer     : ':CUST.NAME
          PRINT 'Contact      : ':CONTACT.NAME
          PRINT
          PRINT 'Subject      : ':SUBJECT
          PRINT

          RETURN
*-------------------------------------------------------------------------*
LOAD.HOTKEYS: *** load hotkeys

          MENU.CLEAR

          MENU.LOAD  3,21,15,1,'S'
          MENU.LOAD 22,21, 5,1,'P'
          MENU.LOAD 30,21,13,10,'C'
          MENU.LOAD 46,21, 7,1,'O'
          MENU.LOAD 56,21, 9,1,'D'

          RETURN
*-------------------------------------------------------------------------*
CLEAR.VARS: *** clear variables

          EMAIL.ADDR    = PASSER<1>
          SUBJECT       = PASSER<5>
          CC            = PASSER<7>
          BCC           = PASSER<8>
          BASATT        = PASSER<9>
          CUSTOMER.FLAG = NO
          CN            = ''
          CUST.NAME     = ''
          CONTACT.FLAG  = NO
          CONT          = ''
          CONTACT.NAME  = ''

          GOSUB DISPLAY

          RETURN
*-------------------------------------------------------------------------*
DISPLAY:  *** display email headings and body

          IF DCOUNT(DIST.LIST<3>,VM) > 1 THEN
             PRINT @(16,1):'*Multi*'                     "L#53"
          END ELSE
             PRINT @(16,1):EMAIL.ADDR                    "L#53"
          END

          IF DCOUNT(CC,VM) > 1 THEN
             PRINT @(16,2):"*Multi*"                     "L#53"
          END ELSE
             PRINT @(16,2):CC                            "L#53"
          END

          IF DCOUNT(BCC,VM) > 1 THEN
             PRINT @(16,3):"*Multi*"                     "L#53"
          END ELSE
             PRINT @(16,3):BCC                           "L#53"
          END

          PRINT @(16,4):SUBJECT                          "L#50"

          * Format attachment title depending upon file extension
          IF PASSER<17> THEN
             ATTACH.MSG = ''
             IF PASSER<9> THEN
                IF PASSER<19> THEN FRMT = PASSER<19> ELSE FRMT = 'TXT'
                ATTACH.MSG = PASSER<17>:' - Send in Body Format ':FRMT
             END ELSE
                IF PASSER<17>[5] = '.html' OR PASSER<18> = '.tiff' THEN
                   ATTACH.MSG = PASSER<17>
                END ELSE
                   IF PASSER<18> THEN
                      ATTACH.MSG = '(':PASSER<18>:')'
                   END ELSE
                      ATTACH.MSG = PASSER<17>
                   END
                END
             END
             PRINT @(16,5):ATTACH.MSG                    "L#62"
          END

          FOR Y = 1 TO 13
             PRINT @(1,Y+6):BODY<1,Y>"L#78"
          NEXT Y

          RETURN
*---------------------------------------------------------------------*
MOUSE$:   GET.MOUSE.POSITION X,Y

          Y -= 1
          BEGIN CASE
          CASE Y=1 AND X>=18 AND X<=49
             RETURN TO IN.ADDR1
          CASE Y=2 AND X>=18 AND X<=49
             RETURN TO IN.CC1
          CASE Y=3 AND X>=18 AND X<=49
             RETURN TO IN.BCC1
          CASE Y=4 AND X>=18 AND X<=69
             RETURN TO IN.SUBJ
          CASE Y GE 7 AND Y LE 19 AND X GE 2 AND X LE 69
             RETURN TO IN.BODY
          END CASE

          RETURN
*-------------------------------------------------------------------------*
FILEIT:   *** file changes and send email - or send back to calling
          *** program to send

          ALL.DONE = NO
          IF DIST.LIST<3> = '' THEN
             ALL.DONE = YES
          END

          * passer 10 is flag that calling pgm will do the send
          IF PASSER<10> THEN
             O.BODY = BODY
             IF PASSER<19> = 'HTML' THEN
                BODY.LINE.CT = DCOUNT(O.BODY,VM)
                FOR JJ = 1 TO BODY.LINE.CT
                   * convert the typed body into html.
                   IF TRIM(O.BODY<1,JJ>) THEN
                      O.BODY<1,JJ> = CHANGE(O.BODY<1,JJ>,' ','&nbsp;')
                   END ELSE
                      O.BODY<1,JJ> = ''
                   END
                NEXT JJ
                O.BODY = CHANGE(O.BODY,VM,'<br>':CRLF)
             END
             ALL.DONE = YES
          END

          IF F12 THEN
             SV.F12 = F12
             CONFIRM.ABORT SURE
             IF NOT(SURE) THEN
                GOTO IN.ADDR
             END
             F12      = SV.F12               ;* To send to EMAIL.DATA.GET
             ALL.DONE = YES
             GOSUB CLEAR.VARS
          END ELSE
             IF DIST.LIST<3> # '' AND NOT(PASSER<10>) THEN

                OK.TO.SEND = YES
                IF TRIM(BODY) = '' AND NOT(PASSER<9> AND PASSER<17>) THEN
                   P.MSG = 'No Body Entered, Delete This Message (Y/N): '
                   RESP  = 'Y'
IN$$1:             INP.PROMPT RESP,P.MSG,'YN',1
                   IF RESP THEN
                      OK.TO.SEND = NO
                      PASSER     = ''
                      IF USE.ECLIPSE.FORMS$ THEN F12 = YES
                   END ELSE
                      GOTO IN.BODY
                   END
                END

                IF OK.TO.SEND THEN
                   MBX.BODY = BODY
                   MBX.BODY = CHANGE(MBX.BODY,VM,AM)
                   MBX.BODY = CHANGE(MBX.BODY,AM,CRLF)

                   * Set the ATTACH.PATH variable from PASSER<17>
                   ATTACH.PATH = PASSER<17>

                   IF PASSER<9> AND ATTACH.PATH THEN
                      OPENSEQ ATTACH.PATH TO MOUTSEQFILE ELSE NULL
                      LOOP
                         READSEQ LINE FROM MOUTSEQFILE ELSE EXIT
                         MBX.BODY := LINE:CRLF
                      REPEAT
                      ATTACH.PATH = ''
                   END

                   * chk if 'Email Letterhead' option has been selected
                   IF PASSER<20> THEN
                      GOSUB LOAD.TEMPLATE
                   END

                   * send the email to all To, CC and BCC addresses
                   TO.LIST       = DIST.LIST<3>
                   CC.LIST       = CC
                   BCC.LIST      = BCC
                   THIS.SUBJECT  = SUBJECT
                   THIS.MBX.BODY = MBX.BODY
                   THIS.TO.LIST  = TO.LIST
                   GOSUB SEND.IT

                   * setup a display list of all emails
                   DISP.ALL.LIST = TO.LIST:VM:CC.LIST:VM:BCC.LIST

                   DISP.ALL.LIST = TRIM(DISP.ALL.LIST,VM)
                   CONVERT VM TO ', ' IN DISP.ALL.LIST

                   * Send the email to the 'Sender BCC' - this is the
                   * email address specified on the Email Options screen.
                   * Note! This is different than the 'BCC' user input in
                   * that this is meant to be an audit user email.
                   * Because it contains additional info, it must be sent
                   * separately.
                   IF PASSER<15> THEN
                      THIS.TO.LIST  = PASSER<15>
                      CC.LIST       = ''
                      BCC.LIST      = ''
                      THIS.SUBJECT  = SUBJECT
                      THIS.MBX.BODY = MBX.BODY

                      * add special BCC Sender audit body text
                      THIS.MBX.BODY<-1> = ' '
                      *THIS.MBX.BODY<-1> ='Message Sent To: ': DISP.ALL.LIST

                      * add special BCC Sender prefix, if it exists
                      IF PASSER<16> THEN
                         THIS.SUBJECT = PASSER<16>:' ':SUBJECT
                      END
                      GOSUB SEND.IT
                   END

                   * log the sent email
                   CN = USER.ID
                   IF CN THEN
                      TYPE = 'U'
                      GOSUB LOG.IT
                   END

                   * done - reset passed in vars
                   PASSER=''; BODY=''; O.BODY=''; MBX.BODY=''
                END
                ALL.DONE = YES
             END ELSE
                * Need to load dist list PASSER
                IF PASSER<10> THEN
                   PASSER<1> = DIST.LIST<3>
                   PASSER<4> = DIST.LIST<2>
                END
                IF (DIST.LIST<3> = '' AND BODY) OR NOT(PASSER<1>) THEN
                   P.MSG = 'No Address Entered, Delete This Message (Y/N): '
                   RESP = 'Y'
IN$$3:             INP.PROMPT RESP,P.MSG,'YN',1
                   IF RESP THEN
                      OK.TO.SEND = NO
                      PASSER = ''
                      IF USE.ECLIPSE.FORMS$ THEN F12 = YES
                   END ELSE
                      GOTO IN.ADDR
                   END
                END
             END
          END

          IF NOT(ALL.DONE) THEN GOTO RESTART ELSE GOTO FINISH
*-------------------------------------------------------------------------*
LOAD.TEMPLATE: *** load the email template

          FORM.NAME = 'Default Email Template'
          WOE.GET.FORM.RESP 'E',FORM.NAME,TEMP.BODY

          ID = 'HTML~':PASSER<22>
          EMAIL.TEMPLATE.GET.RESP COMPANY.NAME,HOME.URL,LOGO,LINKS,ID
          UT.REP.STR TEMP.BODY,'&COMPANY.NAME&',COMPANY.NAME
          UT.REP.STR TEMP.BODY,'&HOME.URL&',HOME.URL
          UT.REP.STR TEMP.BODY,'&LOGO&',LOGO
          UT.REP.STR TEMP.BODY,'&LINKS&',LINKS

          * insert the current MBX.BODY into the template
          MBX.BODY = CHANGE(MBX.BODY,CHAR(13),'<br>':CRLF)
          MBX.BODY = CHANGE(MBX.BODY,' ','&nbsp;')
          UT.REP.STR TEMP.BODY,'&BODY&',MBX.BODY

          * reset MBX.BODY
          MBX.BODY  = TEMP.BODY
          BODY.TYPE = 'HTML'

          RETURN
*-------------------------------------------------------------------------*
SEND.IT:  *** send the email

          * If we're not sending attachment in body, we need
          * to write html file out to disk and tell
          * NETMAIL.OUT to attach it externally
          IF NOT(PASSER<9>) AND PASSER<20> THEN
             READV MPATH FROM VOCFILE,'MSG-OUT',2 ELSE MPATH=''
             GET.PATH LPATH
             FNAME = USER.ID:DATE():TIME():RND(1000):'.html'
             IF OS.TYPE$ = "NT" THEN
                ATTACH.PATH = LPATH:'\':MPATH:'\':FNAME
             END ELSE
                ATTACH.PATH = LPATH:'/':MPATH:'/':FNAME
             END
             WRITE THIS.MBX.BODY ON MOUTFILE,FNAME
             THIS.MBX.BODY = ''
          END

          NETMAIL.OUT THIS.TO.LIST,THIS.SUBJECT,THIS.MBX.BODY,FROM.ADDR,BCC.LIST,CC.LIST,ATTACH.PATH,,BODY.TYPE

          IF NOT(PASSER<9>) AND PASSER<20> THEN
             DELETE MOUTFILE,FNAME
          END

          RETURN
*-------------------------------------------------------------------------*
LOG.IT:   *** log the email send

          IF ATTACH.PATH THEN ATTCH.PTH = SUBJECT ELSE ATTCH.PTH = ''

          * update the email log
          UPDATE.EMAIL.LOG TYPE,CN,TO.LIST,FROM.ADDR,CC.LIST,BCC.LIST,ATTCH.PTH,MBX.BODY

          * update the tracking log
          DISP.TO.LIST  = TO.LIST
          DISP.CC.LIST  = CC.LIST
          DISP.BCC.LIST = BCC.LIST

          CONVERT VM TO ', ' IN DISP.TO.LIST
          CONVERT VM TO ', ' IN DISP.CC.LIST
          CONVERT VM TO ', ' IN DISP.BCC.LIST

          CMT       = 'User ID   : ':CN
          CMT<1,-1> = 'To        : ':DISP.TO.LIST
          CMT<1,-1> = 'CC        : ':DISP.CC.LIST
          CMT<1,-1> = 'BCC       : ':DISP.BCC.LIST
          CMT<1,-1> = 'Sender BCC: ':PASSER<15>
          CMT<1,-1> = 'From      : ':FROM.ADDR
          CMT<1,-1> = 'Subject   : ':SUBJECT
          IF ATTCH.PTH THEN
             CMT<1,-1> = 'Attachment: ':ATTCH.PTH
          END
          ELOG     = ''
          ELOG<67> = 'SYSTEM'
          JOB.TRACKING.CMT CN,CMT,,ELOG

          RETURN
*-------------------------------------------------------------------------*
FINISH:   *** close window and exit
          WINDOW.CLOSE
          RETURN
!TSMITH~08/09/12~09:28
