Sending Email with attachments via REXX



IBM's Command List programming language & Restructured Extended Executor

Sending Email with attachments via REXX

Postby arshadhrashid » Fri Aug 14, 2009 4:48 am

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)"
arshadhrashid
 
Posts: 70
Joined: Tue Jul 28, 2009 5:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sending Email with attachments via REXX

Postby dick scherrer » Fri Aug 14, 2009 7:45 am

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?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Sending Email with attachments via REXX

Postby arshadhrashid » Mon Aug 17, 2009 9:48 pm

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?
arshadhrashid
 
Posts: 70
Joined: Tue Jul 28, 2009 5:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sending Email with attachments via REXX

Postby arshadhrashid » Mon Aug 17, 2009 9:48 pm

And yes I have XMITIP installed
arshadhrashid
 
Posts: 70
Joined: Tue Jul 28, 2009 5:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sending Email with attachments via REXX

Postby dick scherrer » Tue Aug 18, 2009 2:53 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Sending Email with attachments via REXX

Postby arshadhrashid » Tue Aug 18, 2009 3:49 am

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.
arshadhrashid
 
Posts: 70
Joined: Tue Jul 28, 2009 5:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sending Email with attachments via REXX

Postby dick scherrer » Tue Aug 18, 2009 7:38 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Sending Email with attachments via REXX

Postby arshadhrashid » Tue Aug 18, 2009 8:56 pm

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.
arshadhrashid
 
Posts: 70
Joined: Tue Jul 28, 2009 5:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sending Email with attachments via REXX

Postby dick scherrer » Wed Aug 19, 2009 3:23 am

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
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Sending Email with attachments via REXX

Postby MrSpock » Wed Aug 19, 2009 7:31 pm

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.
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post