          SUBROUTINE (DOC.ID,ERR.MSG)
** Version# 2 - 05/21/2007 - 12:23pm - BILLW - main

*** Subroutine - EMAIL.SEND.REPORT
*-------------------------------------------------------------------------*
*** This routine should be used to send an email report from the hold
*** file.  For now, it is used only for phantom scheduled reports
*** (PRINTER.OFF.INIT) but it could be easily plugged in to maunally
*** emailed reports (PRINT.REPORT) as well.
*-------------------------------------------------------------------------*
*** DOC.ID  -  Document ID                                           [IN]
*** ERR.MSG -  any errors encountered                                (OUT)
*-------------------------------------------------------------------------*
*** COMMON Variables:
***       PHANTOM.PROC and JAVA.PROC$ are read but not changed
*-------------------------------------------------------------------------*

          ERR.MSG = ''

          UT.OPEN.FILE '&HOLD&',HOLDFILE,ERR.MSG,YES
          IF ERR.MSG THEN RETURN

          READ RPT FROM RPTFILE, DOC.ID ELSE RETURN
          READ DOC FROM HOLDFILE,DOC.ID ELSE RETURN
          DOC.HDR  = RPT<8>
          DOC.FTR  = RPT<9>
          E.BODY   = RPT<57>         ;* set previously saved body
          PASSER   = RAISE(RPT<58>)  ;* set previously saved email info

          * combine the header, doc and footer
          E.ATTACH = DOC.HDR:VM:DOC:VM:DOC.FTR
          E.ATTACH = TRIM(E.ATTACH,VM)

          * set additional PASSER vars
          IF PASSER<5> = '' THEN
             PASSER<5> = RPT<1>      ;* Subject
          END
          IF PHANTOM.PROC OR JAVA.PROC$ THEN
             PASSER<11> = YES        ;* don't prompt user when sending
          END
          PASSER<10> = YES
          PASSER<13> = YES           ;* don't override attach flag
          IF DOC.ID[5]  = '.html' THEN
             PASSER<18> = '.html'
          END
          PASSER<21> = 'DOC#':DOC.ID ;* attachment name

          EM.DATA = ''
          EM.DATA<11> = 'USER':VM:USER.ID
          EMAIL.DATA.GET EM.DATA,PASSER,E.BODY,E.ATTACH,ERR.MSG
          IF ERR.MSG THEN RETURN

          * Log action taken on this document
          PROC.INFO = RPT<53>
          PROC.ID = PROC.INFO<1,1>
          IF PROC.ID THEN
             PID.REC     = ''
             PID.REC<3>  = PROC.INFO<1,3>
             PID.REC<4>  = PROC.INFO<1,4>
             PID.REC<5>  = USER.ID
             DETAIL      = DOC.ID:VM:'(Email ': PASSER<1,1>:')'
             PROC.ACTION = 'Print'
             UPDATE.PHANTOM.LOG PID.REC,PROC.ID,PROC.ACTION,'','',DETAIL
          END

          RETURN
!BILLW~05/21/07~12:23
