Page 1 of 2

Sending Email with attachments via REXX

PostPosted: Fri Aug 14, 2009 4:48 am
by arshadhrashid
I'm looking for a REXX code to send emails with attachmnets. i found one example but thats without attachments. I'm also not sure where will I find the list of all SMTP. variables used in this example. Also I did not find the SMTP WRITER extension of ALLOCATE command
But following is the example that sends mail without attachmnet and it works.
/* REXX - 08/10/09 */
PARSE ARG RECPT MSG
SMTP.1 = 'HELO' MVSVAR('SYSNAME')
SMTP.2 = 'MAIL FROM:<MYNAME@MYORG.COM>'
SMTP.3 = 'RCPT TO:<'RECPT'>'BNAME")) OLD REUSE"
SMTP.4 = 'DATA'
SMTP.5 = 'FROM MAIN FRAME RACF ID ' MVSVAR('SYSSECLAB')
SMTP.6 = 'TO:' RECPT
SMTP.7 = 'SUBJECT: JES2LOG FOR JOB ' JOBNAME
SMTP.8 = MSG
"ALLOC F(SMTPOUT) SYSOUT(A) WRITER(SMTP)"
   IF RC <> 0 THEN DO
     SAY 'ERROR ALLOCATING SYSOUT FOR SMTP WRITER'
     EXIT 12
     END
SAY 'ALLOCATED ' SMTPOUT
"EXECIO * DISKW SMTPOUT (STEM SMTP. FINIS"
"FREE F(SMTPOUT)"

Re: Sending Email with attachments via REXX

PostPosted: Fri Aug 14, 2009 7:45 am
by dick scherrer
Hello and welcome to the forum,

I've not done this with rexx, but i suspect you will need to identify the dataset to attach by using a FILE or FILEDD. FILE uses a dataset name and FILEDD names a DDNAME.

You might try adding SMTP.9 'FILE your.dataset.name'.

Do you know if your system has XMITIP installed?

Re: Sending Email with attachments via REXX

PostPosted: Mon Aug 17, 2009 9:48 pm
by arshadhrashid
Thanks a lot for your reply.
I tried with SMTP.9 = 'FILE:' FNAME
Where FNAME is asigned to say 'MYFILE' in the code, but I still get an email like

FROM MAIN FRAME RACF ID
TO: myemailaddress
TESTMAIL
FILE: MYFILE

Any idea?

Re: Sending Email with attachments via REXX

PostPosted: Mon Aug 17, 2009 9:48 pm
by arshadhrashid
And yes I have XMITIP installed

Re: Sending Email with attachments via REXX

PostPosted: Tue Aug 18, 2009 2:53 am
by dick scherrer
Hello,

FILE: MYFILE
Does not look like what i posted. . .

Following is what i use to send an attachment using xmitip:
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *   
//MAILSTEP   EXEC  PGM=IKJEFT1B,COND=(0,NE)                         
//*                                                                 
//SYSEXEC    DD   DSN=SYYn.XMITIP.REXXEXEC,DISP=SHR                                   
//XMITMSG    DD   *                                                 
Attached is the Specified Code Update report.                   
                                                                     
/*                                                                   
//SPFDRPT    DD   DSN=&&PRT,DISP=(OLD,DELETE)                             
//SYSTCPD    DD   DSN=MY.DATALIB(TCPIP),DISP=SHR               
//SYSPRINT   DD   SYSOUT=*                                           
//SYSTSPRT   DD   SYSOUT=*                                           
//SYSOUT     DD   SYSOUT=*                                           
//SYSTSIN      DD    *                               
%XMITIP (SomeUser@their.email.com  -     
         another@hotmail.com)             -     
        FROM CENTRALOPS@service.org   -     
        SUBJECT 'Specified Code Update    ' -     
        MSG72 MSGDD XMITMSG                     -     
        FILEDD (SPFDRPT)                             
/*                                                   

This names a dd rather than the dsn in the xmitip control.

Re: Sending Email with attachments via REXX

PostPosted: Tue Aug 18, 2009 3:49 am
by arshadhrashid
Hi Thanks fro your help.

But I dont have any problem with sending email with atachment using JCL as a batch job.
My qesution is about sending this from a REXX command script. I can alreday do it from a batch JCL job.
In rexx I am trying to use XMITIP but I can use any other possible way.

Thanks.

Re: Sending Email with attachments via REXX

PostPosted: Tue Aug 18, 2009 7:38 am
by dick scherrer
Hello,

In rexx I am trying to use XMITIP but I can use any other possible way.
The posted rexx code does not appear to be using xmitip. . . XMITIP is not required to send e-mail.

But I dont have any problem with sending email with atachment using JCL as a batch job.
It may help if you post the batch job you successfully run.

You might consider using the rexx code to submit the batch job that successfully sends the required e-mail.

Re: Sending Email with attachments via REXX

PostPosted: Tue Aug 18, 2009 8:56 pm
by arshadhrashid
You are right my posted code doenot use REXX this is why I was saying that I can use any other method.
here is the situation now.

I am unable to send email with atachmnet via the posted REXX code or for that matter any other REXX code.
I can use JCL to use XMITTP and send attatchment successfully.

As per your advice I will now try to wite a REXX that will genrate this JCL unless you haev any other REXX code to accomplsh this.

Thaks a lot.

Re: Sending Email with attachments via REXX

PostPosted: Wed Aug 19, 2009 3:23 am
by dick scherrer
Hello,

Writing the jcl to be submitted should not be very difficult. What you submit should look very similar to the sample i posted.

When you added the new file statement to the rexx, it does not appear to be as i posted. If you want a rexx-only method, you may want to experiment with the smtp.9 statement. It may be a matter of getting the quotes correct. You might try putting the dsn in a variable (like JOBNAME is) and then the statement might be:
SMTP.9 'FILE ' dsnvrbl

Re: Sending Email with attachments via REXX

PostPosted: Wed Aug 19, 2009 7:31 pm
by MrSpock
I'm NOT going to provide any proprietary code, but it's not too difficult to write a REXX exec that uses the z/OS Communications Server socket API for REXX calls:

http://publibfp.boulder.ibm.com/epubs/pdf/f1a1d460.pdf

Just follow the details of SMTP (for email) and MIME (there's a different protocol for SMTP file attachments) as documented in the Internet RFC standards and you should have no problems.