IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX to send an email in Mainframe


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Sat Oct 01, 2022 11:00 pm
Reply with quote

Hi All,

Using below REXX am able to send an email without any issue.
Code:

/* REXX */                                             
 LPAR = 'TEST LPAR '                                   
SMTP.1 = 'HELO' MVSVAR('SYSNAME')                     
SMTP.2 = 'MAIL FROM:<TEST123@CAP.NET>'                 
SMTP.3 = 'RCPT TO:<TEST123@CAP.NET>'                   
SMTP.4 = 'DATA'                                       
SMTP.5 = 'FROM:<TEST123@CAP.NET>'                     
SMTP.6 = 'TO:<TEST123@CAP.NET>'                       
SMTP.7 = 'SUBJECT:'LPAR'-DETAILS'                     
SMTP.8 =  'THESE DETAILS ARE TEST LPAR DETAILS '       
"ALLOC F(SMTPOUT) SYSOUT(B) WRITER(SMTP)"             
IF RC <> 0 THEN DO                                     
  SAY 'ERROR ALLOCATING SYSOUT FOR SMTP WRITER'       
  EXIT 12                                             
END                                                   
"EXECIO * DISKW SMTPOUT (STEM SMTP. FINIS"             
IF RC <> 0 THEN DO                                     
  SAY 'ERROR WRITING SYSOUT FOR SMTP WRITER'           


But in my email body am getting below message
THESE DETAILS ARE TEST LPAR DETAILS

My query is, Incase if I keep my email body message in a mainframe PS dataset then how can represent dataset name in above rexx code?

Any suggestions?

Upensri
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2594
Location: Silicon Valley

PostPosted: Sun Oct 02, 2022 12:26 am
Reply with quote

You would just need to copy from your input data set to the SYSOUT(B) file. I suggest to use IEBGENER utility. Something like this (untested):
Code:
/*rexx */
Address TSO
"ALLOC FILE(SYSIN) DUMMY REU"
"ALLOC FILE(SYSPRINT) BLKSIZE(2660) LRECL(133) NEW REU",
            " SPACE(1,1) TRACK RECFM(F,B) "
"ALLOC FILE(SYSUT1) DA(my.email.txt) SHR REU"
"ALLOC FILE(SYSUT2) SYSOUT(B) WRITER(SMTP)"
Address LINKMVS "IEBGENER"
say 'IEBGENER rc=' rc
If rc \= '0' Then
  Do
    "EXECIO * DISKR SYSPRINT ( FINIS  STEM OUTPUT."
    Do xx = 1 to output.0
      say output.xx
    End
  End
"FREE FILE(ISYSIN,SYSPRINT,SYSUT1,SYSUT2)"
Exit 0



Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Sun Oct 02, 2022 7:11 am
Reply with quote

Code:

/* REXX */                                             
 LPAR = 'TEST LPAR '     

/* put SMTP header into program stack */                             
Queue 'HELO' MVSVAR('SYSNAME')                     
Queue 'MAIL FROM:<TEST123@CAP.NET>'                 
Queue 'RCPT TO:<TEST123@CAP.NET>'                   
Queue 'DATA'                                       
Queue 'FROM:<TEST123@CAP.NET>'                     
Queue 'TO:<TEST123@CAP.NET>'                       
Queue 'SUBJECT:'LPAR'-DETAILS'       
             
/* Queue 'THESE DETAILS ARE TEST LPAR DETAILS ' */

"ALLOC FILE(MSGTEXT) DA(‘library(member)’) SHR REU"
IF RC <> 0 THEN DO
   SAY ‘ERROR ALLOCATING MSGTEXT FOR SMTP MESSAGE’
   EXIT 12
END
“EXECIO * DISKR MSGTEXT (FINIS” /* read whole text into program stack */
“FREE F(MSGTEXT)”

"ALLOC F(SMTPOUT) SYSOUT(B) WRITER(SMTP)"             
IF RC <> 0 THEN DO                                     
  SAY 'ERROR ALLOCATING SYSOUT FOR SMTP WRITER'       
  EXIT 12                                             
END         

/* write from program stack to SMTP output */                                         
"EXECIO” Queued() “DISKW SMTPOUT ( FINIS"             
IF RC <> 0 THEN DO                                     
  SAY 'ERROR WRITING SYSOUT FOR SMTP WRITER'         
   EXIT 12
END
“FREE F(SMTPOUT)”
RETURN 
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Sun Oct 02, 2022 2:01 pm
Reply with quote

Hi sergeyken

Its working ..

Great thanks..
Back to top
View user's profile Send private message
upendrasri

Active User


Joined: 28 Sep 2017
Posts: 124
Location: India

PostPosted: Sun Oct 02, 2022 2:02 pm
Reply with quote

Hi Pedro,

Thanks for your suggestion. I tried with IEBGENER and its working fine...

Great thanks.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top