send email with an attachment from the mainframe

Other Mainframe related questions which attracts you and there is no suitable Forum you find for it and related FAQs.
Post Reply
Arun Rajput
Registered Member
Posts: 16
Joined: Tue Jan 20, 2015 8:40 am
India

send email with an attachment from the mainframe

Post by Arun Rajput »

Hi,

Can anyone help on How to send email with an attachment from the mainframe?

Thanks,
 
User avatar
zum13
Active Member
Posts: 127
Joined: Thu May 04, 2023 12:58 am

Re: send email with an attachment from the mainframe

Post by zum13 »

Hello.

I've sent emails from jobs in the past, but not attachments. Emailing involves the "SMTPNOTE" command, the TSO "TRANSMIT" command or the SMTP external reader. From the documentation, none of these appear to have been explicitly set up to handle attachments: https://www.ibm.com/docs/en/zos/3.1.0?t ... pplication

This is not to say that it is not possible. There is an example shown here: https://www.ibm.com/docs/en/zos/3.1.0?t ... tpiebgener . The file that is being sent is constructed using commands from the SMTP protocol (HELO, MAIL FROM:, RCPT TO:, etc), the idea being that if you can write something that produces the same kind of thing, the SMTP daemon will be able to send it.

In order to send an attachment, you would need something that would not only write the necessary SMTP commands but the MIME protocol (which is what allows attachments to happen). There are various command line utilities around that will do this on other systems (e.g. mailx, mutt). There are also extensions within Python and other scripting languages that will let you do it (for example, see https://keentolearn.medium.com/automati ... a00fa98b92). The problem is that they while they may be runnable under USS, they may not necessarily understand the environment they are running in and they may try to bypass the SMTP daemon as a result. However, if one of these utilities can be made to write it's work to a file complete with SMTP protocol commands then it can be sent using z/OS's facilities as per the IEBGENER example.

One thing you would need to be wary of is ensuring that the file you are sending is not EBCDIC if the user/system you are sending to cannot handle it.

Sorry I cannot be of more help than that. Hopefully there's someone on here who's actually done it in practice.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1903
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: send email with an attachment from the mainframe

Post by Robert Sample »

Find and study RFC 5321, which is the Internet standard way to use SMTP to send mail.  Sending attachments usually requires experimentation as the format is EXTREMELY picky and one wrong character may cause the attachment to not send.  Also, your site must have enabled the SMTP writer.  I recommend starting with a simple email (no attachment), getting it to work, then expanding to a text attachment, then finally to using MIME attachments.
User avatar
myoggradio
Registered Member
Posts: 15
Joined: Tue Jul 30, 2024 8:15 pm
Germany

Re: send email with an attachment from the mainframe

Post by myoggradio »

We have a Java program that works with Java 8 and is based on Oracle's mail.jar.
Here is the JCL to run the program.
If required, I will send you the *.jar files.
Please note that it no longer works with Java 11.
If you want, you can receive the source code or the jar file by email. 

Code: Select all

//SENDMAIL JOB (430430137),'D42313',MSGCLASS=Q,MSGLEVEL=(1,1), 
// NOTIFY=&SYSUID,CLASS=S,REGION=0M                    
//JAVA EXEC PROC=JVMPRC80,LOGLVL='+T',                         
// JAVACLS='pack.Main'                                         
//STDENV DD *                                                  
. /vwb/sysprog/profile8                                        
CLASSPATH=$CLASSPATH:/vwb/sysprog/java/zosMail                 
CLASSPATH=$CLASSPATH:/vwb/sysprog/javalib/mail.jar             
//*                                                            
//PARM DD *                                                    
SUBJECT=IPLINFO - VBP1 + VBP2 - Job SENDMAIL                   
FROM=christian@gibtnich.de                             
TO=christian@gibtnich.de                           
TXTDD=APPENDIX1                                                  
TXTDD=APPENDIX2                                                  
ENCODING=ISO-8859-1                                            
/*                                                             
//APPENDIX1 DD DISP=SHR,DSN=D42313.SYSPRINT.IPLINFO.VBP1         
//APPENDIX2 DD DISP=SHR,DSN=D42313.SYSPRINT.IPLINFO.VBP2         
//TEXT DD *                                                    
Attached is the current IPL info                                    
/                                                             
*//* Valid parameters are:                                          
//* SUBJECT                                                          
//* Subject of the email                                               
//* FROM                                                              
//* Sender                                                        
//* TO                                                             
//* Recipient                                                      
//* Header card can be specified multiple times                     
//* CC                                                               
//* Carbon Copy                                                     
//* Header card can be specified multiple times                     
//* BCC                                                              
//* Blind Carbon Copy                                               
//* Header card can be specified multiple times                     
//* ATT                                                              
//* Name of an Open MVS file that is sent as an attachment in binary form 
//* e.g.: /u/D42313/OpenJPA.pdf                                     
//* Header card can be specified multiple times                     
//* DD                                                               
//* Name of a Jes file that is sent as an attachment in binary form;     
//* maximum 8 characters.                                              
//* Header card can be specified multiple times                     
//* TXTDD                                                            
//* Name of a Jes text file that is sent as an attachment;       
//* maximum 8 characters.                                              
//* Header card can be specified multiple times                     
//* ENCODING                                                         
//* Character set of the email and the text attachment                      
//* MAXCHARACTERS                                                       
//* Maximum number of characters in the email (without attachment)          
//* SMTPSERVER                                                       
//* TCP/IP address of the mail server; only specify as an exception        
//* SMTPPORT                                                         
//* TCP/IP port of the mail server; only specify as an exception           
User avatar
myoggradio
Registered Member
Posts: 15
Joined: Tue Jul 30, 2024 8:15 pm
Germany

Re: send email with an attachment from the mainframe

Post by myoggradio »

Habe den Quelltext mal angehängt
You do not have the required permissions to view the files attached to this post.
User avatar
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 843
Joined: Wed Sep 11, 2013 3:57 pm

Re: send email with an attachment from the mainframe

Post by enrico-sorichetti »

did Your organization consider XMITIP

https://groups.io/g/xmitip
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
Arun Rajput
Registered Member
Posts: 16
Joined: Tue Jan 20, 2015 8:40 am
India

Re: send email with an attachment from the mainframe

Post by Arun Rajput »

Thank you everyone for the pointers. I am new to it all, I am working on it. Will get back you how it works out. 
Arun Rajput
Registered Member
Posts: 16
Joined: Tue Jan 20, 2015 8:40 am
India

Re: send email with an attachment from the mainframe

Post by Arun Rajput »

enrico-sorichettidid Your organization consider XMITIP

https://groups.io/g/xmitip
I am not sure about it, I shall ask around about it.
User avatar
Anuj Dhawan
Founder
Posts: 2824
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: send email with an attachment from the mainframe

Post by Anuj Dhawan »

@myoggradio - I have added the code tags to your post. Kindly review them to ensure they are correct.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
User avatar
myoggradio
Registered Member
Posts: 15
Joined: Tue Jul 30, 2024 8:15 pm
Germany

Re: send email with an attachment from the mainframe

Post by myoggradio »

Hallo Anuj,
Danke für Deine Mühe die Tags zu setzen.
Aber eigentlich ist Alles eine zusammenhängende JCL.
Gruß Christian
User avatar
Anuj Dhawan
Founder
Posts: 2824
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: send email with an attachment from the mainframe

Post by Anuj Dhawan »

Hi Christian,

Kindly confirm if this meets your expectations, and please feel free to provide any further feedback.

Regards,
User avatar
myoggradio
Registered Member
Posts: 15
Joined: Tue Jul 30, 2024 8:15 pm
Germany

Re: send email with an attachment from the mainframe

Post by myoggradio »

Super, so ist es gut
Arun Rajput
Registered Member
Posts: 16
Joined: Tue Jan 20, 2015 8:40 am
India

Re: send email with an attachment from the mainframe

Post by Arun Rajput »

Thank you everyone for your help. We are working on our process to make it work, based on the inputs. 
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “Other Mainframe Topics, Off-Topics, FAQs.”