[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

[sqr-users] unix email in SQR



I'm having a problem having my Unix machine send mail messages from SQR, and
I dont understand why.  I know that all of my select logic and program logic
is correct.  The program does everything it's supposed to except send the
message to us to let us know it did it.  In the log message I get the error
'Error sending e-mail to: bstone@fastenal.com'  ...which is the message I
make with the 'show' statement when the #unix_status returns some non-0
value (error value).  

In my opinion, this error has something to do with the string that I'm
passing to the

I had this working before in our production environment, but it stopped
working when I started using the DIST_REGION_INFO procedure.  In my opinion,
this error has something to do with the string I pass into the
body...because that's the only part that's changed since it was working.
the command I pass is:  (echo "body") | mailx -s "subject"
bstone@fastenal.com

Does someone see something wrong with the string I'm making?  Are there some
sort of protected Unix characters that I'm messing with inside the "body"
section?  please let me know if you have any ideas.

Thanks

Bob Stone  
Fastenal Inventory Developer

Here's a shortened version of the code:
!*******************************************************************
begin-procedure MAIN
!*******************************************************************
ENCODE '<13>' INTO $cr
let $new_bu_email_body = 'BUs were added to Inventory Interfaces on ' 
     || $current_date || '. ' || $cr || $cr || '-----' || $cr || $cr

BEGIN-SELECT
t.business_unit     &t.business_unit
     let $business_unit = &t.business_unit
     if **case one
          let $ps_live = 'Y'
          let $new_bu_email_body = $new_bu_email_body ||$business_unit || '
- added to fas_intfc_ty.  PS live.' || $cr
     end-if
     if **other case
          let $ps_live = 'N'
          let $new_bu_email_body = $new_bu_email_body ||$business_unit || '
- added to fas_intfc_ty.  not PS live.' || $cr
     end-if
     do dist_region_info($business_unit)  !possibly something in this
procedure??
     do other_processing
FROM sysadm.some_tables
WHERE {$clause}
END-SELECT

! there are 2 other selects which add to $new_bu_email_body in the exact
same way as above. not the problem.

if $new_bu_found = 'Y'
     let $email_subject = 'New BUs added to PeopleSoft Inventory
Interfaces.'
     do email-message('IN', 'FASIN176', $email_subject,  $new_bu_email_body)
end-if
end-procedure MAIN

!*******************************************************************
begin-procedure dist_region_info($bu)
!*******************************************************************
begin-select
dist            &district
dist_descr      &district_descr
reg             &region_code
reg_descr       &regional_descr
     let $dist = &district
     let $dist_descr = &district_descr
     let $reg = &region_code
     let $reg_descr = &regional_descr
     let $_new_bu_email_body = $_new_bu_email_body || '     REGION: ' ||
$reg  || ', ' || $reg_descr || '.  '
     let $_new_bu_email_body = $_new_bu_email_body || 'DISTRICT: ' || $dist
|| ', ' || $dist_descr || '. ' || $_cr
from sysadm.ps_fas_rmdm_vw
where business_unit = $bu
end-select
end-procedure dist_region


!*******************************************************************
begin-procedure email-message($module, $prog_name, $subject, $body)
!*******************************************************************
begin-SELECT 
email_address 
      let $email_address =ltrim( rtrim(&email_address, ' '), ' ')
      let $command = '(echo "' || $body || '") | mailx -s "' || $subject ||
'" ' || $email_address
      show $command
      call system using $command #unix_status   
      if #unix_status <> 0
        show 'Error sending e-mail to: ' $email_address
      end-if 
from ps_fas_email_tbl
where {$clause}
end-select
end-procedure



_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users