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

email an attachment through JCL


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
neeraj_pathak26

New User


Joined: 02 Jun 2006
Posts: 7

PostPosted: Thu Jun 19, 2008 1:22 pm
Reply with quote

Hi , I am trying to send a report which is a sequential dataset to certain group as email.
I use a below step to do normal emailing through jcl
Code:
//STEP040  EXEC PGM=IEBGENER             
//SYSPRINT DD SYSOUT=*                   
//SYSIN    DD DUMMY                       
//SYSUT1   DD DISP=SHR,DSN=TEST.EMAIL.INFO
//         DD DISP=SHR,DSN=TEST.REPORT   
//SYSUT2   DD SYSOUT=A,DEST=(destination),
//            DCB=(RECFM=F,BLKSIZE=133)


TEST.EMAIL.INFO has below information
Code:
[i][b]HELO XXXXXXX                         
MAIL FROM:<SOURCE>                   
RCPT TO:<NEERAJ@REDIFF.COM>         
DATA                                 
DATE:                               
FROM:     TESTJOB                   
TO:       GROUP                     
SUBJECT:  TEST REPORT FOR THIS MONTH. [/b][/i]


and TEST.REPORT has the information which I want to email.

If I use the above step it sends the email having all the report data in the mail it self, but I want to email TEST.REPORT as an attachment.
[/code]
Back to top
View user's profile Send private message
Srinivasa Rao

New User


Joined: 21 Jun 2005
Posts: 75

PostPosted: Thu Jun 19, 2008 4:33 pm
Reply with quote

Hi Neeraj,

You need to specify boundries as below. Try it.


//STEP010 EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=B,DEST=SMTP
//SYSUT1 DD *
helo JESNDIXA
mail from:<XXXXXX@JESNDIXA>
rcpt to:<XXXXXXX@XXXXX.COM >
data
From: MAINFRAME
To: XXXXXXXX@XXXXXX.com
Subject: Test attachment
MIME-Version: 1.0
Content-type: multipart/mixed;
boundary="simple boundary"
--simple boundary
CONTENT-TYPE: TEXT/PLAIN; CHARSET="US-ASCII"
CONTENT-TRANSFER-ENCODING: 7BIT
Hello,
Please find a test email with attachment sent via SMTP:


--simple boundary
--simple boundary
CONTENT-TYPE: APPLICATION/OCTET-STREAM;
CONTENT-DISPOSITION:ATTACHMENT;FILENAME="Vault.doc"
/*
// DD DISP=SHR,DSN=GADMPD.CA1.VMSRPT.BRIT
// DD *
--simple boundary
--simple boundary
CONTENT-TYPE: TEXT/PLAIN; CHARSET="US-ASCII"
CONTENT-TRANSFER-ENCODING: 7BIT

Regards
-Srinivasa

--simple boundary
Back to top
View user's profile Send private message
neeraj_pathak26

New User


Joined: 02 Jun 2006
Posts: 7

PostPosted: Mon Jun 23, 2008 10:38 am
Reply with quote

Hi Srinivasa,
I tried this one, but It seems it did not work, I got the email but there were no attachment, all details came in email only which I wanted to send as attachment. Along with the email data I got sysin data also

BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN; CHARSET="US-ASCII"
CONTENT-TRANSFER-ENCODING: 7BIT
HELLO,
PLEASE FIND A TEST EMAIL WITH ATTACHMENT SENT VIA SMTP:
--SIMPLE BOUNDARY
--SIMPLE BOUNDARY
CONTENT-TYPE: APPLICATION/OCTET-STREAM;
CONTENT-DISPOSITION:ATTACHMENT;FILENAME="VAULT.DOC"
Quote:


I appreciate your help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 23, 2008 5:27 pm
Reply with quote

This code sends the data as a text attachment:
Code:
//MAILPROC EXEC PGM=IEBGENER
//SYSABEND DD   SYSOUT=*
//SYSTOTAL DD   SYSOUT=*
//SYSLIST  DD   SYSOUT=*
//SYSPRINT DD   SYSOUT=*
//SYSUT2   DD   SYSOUT=(9,SMTP)
//SYSIN    DD   DUMMY
//*
//SYSUT1 DD *
HELO MAINFRAME.********
MAIL FROM: <MAINFRAME@********>
RCPT TO: <RSAMPLE@********>
DATA
FROM:     MAINFRAME@********
TO:       ROBERT SAMPLE
SUBJECT:  TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT
//       DD DSN=TTSSRS0.JCL.CNTL(EMAILATT),DISP=SHR
//       DD DSN=TTSSRS0.JCL.CNTL(EMAILAT),DISP=OLD
Back to top
View user's profile Send private message
neeraj_pathak26

New User


Joined: 02 Jun 2006
Posts: 7

PostPosted: Tue Jun 24, 2008 3:02 pm
Reply with quote

Hi Robert,
Thanks for Reply.
Can you please let me know that what the control cards are containing? below are the control cards you have coded in your jcl.
Quote:
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT
// DD DSN=TTSSRS0.JCL.CNTL(EMAILATT),DISP=SHR
// DD DSN=TTSSRS0.JCL.CNTL(EMAILAT),DISP=OLD.


Also which dataset will go as FILE.TXT in the email?
I appreciate your help!
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 24, 2008 3:19 pm
Reply with quote

The data in TTSSRS0.JCL.CNTL(EMAILATT) becomes the attachment. The EMAILAT member is a single period on a line by itself (required by RFC 2821).
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Jul 03, 2008 7:46 pm
Reply with quote

Hi,

I have 3 reports to send daily. Ihave coded such that to attach a single report. But i am unable to attach all the three report in a single mail. Do any one have an idea on this? Please advise
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Fri Jul 04, 2008 3:18 pm
Reply with quote

Any positive resolutions????
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Fri Jul 04, 2008 7:17 pm
Reply with quote

If i try to include
"Hello,
Please find a test email with attachment sent via SMTP:
"

I am not getting in mail. if i try with alternate way it's coming in the attachement itself. Please advise.
Back to top
View user's profile Send private message
jack.arden

New User


Joined: 30 Jan 2009
Posts: 3
Location: New Jersey

PostPosted: Sat Jan 31, 2009 3:08 am
Reply with quote

I have tried the above approach and the report is appearing in the body of the e-mail not as an attachment. Also, this only works if the dataset to be sent is 80 bytes, if it is 133 as any report I get a JCL error.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Sat Jan 31, 2009 3:24 am
Reply with quote

If you're concatenating datasets, make sure you follow the rules of concatenation (they should all have the same RECFM and LRECL) in your job ...
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sat Jan 31, 2009 3:54 am
Reply with quote

Hi,



Quote:
this only works if the dataset to be sent is 80 bytes, if it is 133 as any report I get a JCL error.


I doubt this would result in a JCL error, maybe a non zero return code or an abend.


Gerry
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Jan 31, 2009 4:08 am
Reply with quote

Hello Jack and welcome to the forum,

It will probably help if you post the jcl/control statements used along with the actual error message(s) and the id's that go with them. . .

When posting jcl, code, etc, it is best to use copy/paste and the "Code" tag (top center of the reply panel). Use Preview see how your post will appear to the forum and when you are satisfied, Submit.

Please do not attach screenshots. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jan 31, 2009 5:02 am
Reply with quote

I've got someone at work that uses this format to send 998-byte records. The SYSUT1 DD statement points to a DSNAME with LRECL=998, and the concatenated files are both LRECL=998. This works fine in production every day for us. The MAIL FROM and RCPT TO fields are different but they and the other statements are all part of the LRECL=998 dataset.
Back to top
View user's profile Send private message
jack.arden

New User


Joined: 30 Jan 2009
Posts: 3
Location: New Jersey

PostPosted: Mon Feb 02, 2009 8:51 pm
Reply with quote

The jcl submitted is:
Code:

//EXT2MAIL EXEC PGM=IEBGENER                                 
//SYSABEND DD   SYSOUT=*                                     
//SYSTOTAL DD   SYSOUT=*                                     
//SYSLIST  DD   SYSOUT=*                                     
//SYSPRINT DD   SYSOUT=*                                     
//SYSUT2   DD   SYSOUT=(9,SMTP)                               
//SYSIN    DD   DUMMY                                         
//*                                                           
//SYSUT1 DD *                                                 
HELO       CHAR.MVS.US.XXX.COM                               
MAIL FROM: <JARDEN@XXX.COM>                                   
RCPT TO:   <JARDEN@XXX.COM>                                   
DATA                                                         
TO: <JARDEN@XXX.COM>                                         
FROM: <APP1JJAX JOB>                                         
SUBJECT: TEST E-MAIL NOTIFICATION                             
===============================================
   JOB APP1JJAX COMPLETED (SEE ATTACHMENT)                   
MIME-VERSION: 1.0     
CONTENT-TYPE: TEXT/PLAIN                                 
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT       
//       DD DSN=APP.APP1JJA.REPORT1,DISP=SHR             
//       DD DSN=APP.APP1JJA.JCL(PERIOD),DISP=SHR         
//                                                                               

The e-mail received is:

===============================================
JOB APP1JJAX COMPLETED (SEE ATTACHMENT)
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT
N828TEST TEST REPORT

NAME ADDRESS

JOHN DOE 123 MAIN STREET ANYTOWN, NJ 07000

JANE DOE 999 ANOTHER RD ATOWN, NY 11200

.


Notice the "." at the end. What I want is for the part starting at N828TEST to be in an attachment.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Feb 02, 2009 9:11 pm
Reply with quote

Where's all of the MIME protocol code? All I see is the SMTP protocol code. There looks to be a lot missing, unless it's included in one of the concatenated datasets.
Back to top
View user's profile Send private message
jack.arden

New User


Joined: 30 Jan 2009
Posts: 3
Location: New Jersey

PostPosted: Wed Jun 10, 2009 1:27 am
Reply with quote

MIME protocol code??? Please provide sample
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Jun 10, 2009 2:08 am
Reply with quote

Planet MVS MVS Mail page.
Back to top
View user's profile Send private message
Nair47

New User


Joined: 13 Jun 2009
Posts: 2
Location: vizag

PostPosted: Sat Jun 13, 2009 6:15 pm
Reply with quote

can any one please tell me....wat is this helo ***** means.
when iam trying to execute the code iam getting maxcc=0, but mail is not been sent.


//G107525J JOB ,,NOTIFY=&SYSUID,CLASS=B,MSGLEVEL=(1,1),MSGCLASS=X
//IEBGENER EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(B,SMTP)
//SYSOUT DD SYSOUT=*
//SYSUT1 DD *
HELO 192.168.100.74
MAIL FROM :<mailid1>
RCPT TO :<mailid2>
DATA
FROM :<mailid1>
TO :<mailid2>
SUBJECT:TEST
HI..... WAT DOING?
REGARDS,
RAJESH
/*
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jun 13, 2009 7:07 pm
Reply with quote

To find out what the HELO means, pull up the IETF document RFC 2821 and read it. This document gives you the exact specifications for Internet emails and the different options there of. Google can help you find it.

How do you know the mail has not been sent? Since you obfuscated the precise email address, I recommend you contact your site support group and have them check the SMTP job output to see if your email did, indeed, get sent. Note that having the email go out of the mainframe does not mean you will see it at <mailid2>. That would depend upon whether the mail server was set up appropriately to handle mainframe emails. You really, really, really must get site support people involved to resolve this since there are a number of areas where an email can go awry and only they can help you figure out what is going on.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Jun 14, 2009 2:13 am
Reply with quote

Hello,

In addition to what Robert mentioned, it may be that the mail was sent, but was denied some way (treated as junk, deleted, rejected, etc) by the receiving e-mail system.
Quote:
You really, really, really must get site support people involved
Yup, you really really should. . .
Back to top
View user's profile Send private message
Nair47

New User


Joined: 13 Jun 2009
Posts: 2
Location: vizag

PostPosted: Mon Jun 15, 2009 6:00 pm
Reply with quote

hi,
thank u so much....one of my freind had written the same code....but this worked for him.....and i recieved mail sent by him through main frame....every thing was fine...but the thing is he has sent me using vsam file......but this didnot work for me when i tried for it directly....the main frame server name and mails every thing supports the mainframe mails....
Back to top
View user's profile Send private message
Srinivas46

New User


Joined: 03 Oct 2009
Posts: 4
Location: Chennai

PostPosted: Sat Feb 27, 2010 8:33 am
Reply with quote

Hi,

I was able to use the code to send an email with attachement as a Text file. Now, my requirement is as follows:
I have a huge MS word document (around 20 MB) which was compressed using ZIP and then FTP'ed to a mainframe dataset in Binary format.
I want an email to be sent with the MS Word doc (or the ZIP file) as an attachment. Can this be done thru JCL ?

Please let me know if it can be done thru any other means.

Thanks,
Srinivas

Robert Sample wrote:
This code sends the data as a text attachment:
Code:
//MAILPROC EXEC PGM=IEBGENER
//SYSABEND DD   SYSOUT=*
//SYSTOTAL DD   SYSOUT=*
//SYSLIST  DD   SYSOUT=*
//SYSPRINT DD   SYSOUT=*
//SYSUT2   DD   SYSOUT=(9,SMTP)
//SYSIN    DD   DUMMY
//*
//SYSUT1 DD *
HELO MAINFRAME.********
MAIL FROM: <MAINFRAME@********>
RCPT TO: <RSAMPLE@********>
DATA
FROM:     MAINFRAME@********
TO:       ROBERT SAMPLE
SUBJECT:  TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT
//       DD DSN=TTSSRS0.JCL.CNTL(EMAILATT),DISP=SHR
//       DD DSN=TTSSRS0.JCL.CNTL(EMAILAT),DISP=OLD
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Feb 27, 2010 9:06 am
Reply with quote

Hello,

Is XMITIP available on your system?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 27, 2010 5:33 pm
Reply with quote

Quote:
I have a huge MS word document (around 20 MB) which was compressed using ZIP and then FTP'ed to a mainframe dataset in Binary format.
I want an email to be sent with the MS Word doc (or the ZIP file) as an attachment. Can this be done thru JCL ?
No -- JCL does nothing but execute programs. If you wanted to use a utility like IEBGENER to do this, that would work. But since JCL does nothing by itself, you cannot do anything "thru JCL".

Even if you use a utility such as IEBGENER, you have to consult with your site support group. They have established a limit on the size of the SMTP email (the default is 512K), and unless that limit is larger than the size of the document you are attempting to email, it cannot be sent via SMTP.
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 -> All Other Mainframe Topics Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts mail attachment with excel format All Other Mainframe Topics 2
No new posts REXX to send an email in Mainframe wi... CLIST & REXX 3
No new posts REXX to send an email in Mainframe CLIST & REXX 4
No new posts Problem while sending special charact... JCL & VSAM 4
No new posts TXT2PDF and then SMTP email a PDF JCL & VSAM 4
Search our Forums:

Back to Top