Zip the File on Mainframe and send as E-Mail Attachment

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
RGBM_SUN1
Member
Posts: 2
Joined: Thu Nov 25, 2010 9:28 pm

Zip the File on Mainframe and send as E-Mail Attachment

Post by RGBM_SUN1 » Thu Nov 25, 2010 9:51 pm

Hi,

My Req is to send an E-mail with an Zipped Excel attachment from Mainframe. i.e. Convert the PS File on Mainframe to Excel file on Mainframe and then Zip it and send it as attachment.

Iam able to convert the PS File into an Excel format file on Mainframe using SAS ODS feature. But not able to Zip it. I have PKZIP Installed on the machine.

//PKZIP EXEC PGM=PKZIP,REGION=0M
//SYSPRINT DD SYSOUT=*
//ZIPCUR DD DSN=XXXX.ABCD.EGFT,DISP=SHR
//OUTARCH DD DSN=XXXX.ABCD.EGFT.ZIP,DISP=(NEW,CATLG,DELETE),
// DCB=(LRECL=8196,BLKSIZE=27998,RECFM=VB),UNIT=SYSALLDA
//SYSIN DD *
-ECHO
-ADD
-NOPATH
-ARCHOUTDD(OUTARCH)
-INDD(ZIPCUR)
//*

Then send the Zip file as below using IEBGENER
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/XML
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=REPORT.ZIP
I got a Zip file as attachment. But it gives the error on opening it to Unzip.

CANNOT OPEN FILE: IT DOES NOT APPEAR TO BE A VALID ARCHIVE

Looks like the problem is with the Zip file on Mainframe and not with the E-Mail step. As the same error appears when i FTP the Zippped file to Windows and try Unzipping it.

Can anyone please let me know what parameters are to be added to properly Zip the file. And what should be the CONTENT-TYPE provided in the E-Mail step (Using IEBGENER or SAS)?

Thanks.

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Fri Nov 26, 2010 6:42 am

I can't help you with the PKZIP step unless you want to include some error messages or anything else that might help.

As far as using MIME for the attachment, I'm pretty sure a binary file would be coded as:

Content-Type: multipart/mixed;

or possibly:

Content-Type: application/zip;

Now, I'm no MIME expert, and you can look this up just as easily as I can, but I think that you have to encode the attachment using BASE64 encoding. If I recall, SAS will properly encode the attachment without you needing to do anything special.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Fri Nov 26, 2010 5:26 pm

i have tried this 2 years back and it is worked out.
Let me try to get that info for you. In my next post, i will try to give that info to you.
Natarajan
Chennai

RGBM_SUN1
Member
Posts: 2
Joined: Thu Nov 25, 2010 9:28 pm

Post by RGBM_SUN1 » Fri Nov 26, 2010 5:45 pm

Thank You.

There are no Error Messages in the PKZIP Step Spool.

-ECHO
-ADD
-ACTION(ADD)
-NOPATH
-PATH(N)
-ARCHOUTDD(OUTARCH)
ZPDA000I DSNAME=XXXX.XXXX.XXXX.CSV.ZIP,DISP_STATUS=NEW
ZPDA000I DISP_NORMAL=CATALOG,DISP_ABNORMAL=,SPACE_TYPE=TRK
ZPDA000I SPACE_TYPE=CYL,SPACE_TYPE=BLK,SPACE_PRIMARY=4194304
ZPDA000I SPACE_DIRBLKS=2097166,INFO_ALCFMT=00,VOLUMES=PRMH05,INFO_CNTL=
ZPDA000I INFO_STORCLASS=,INFO_MGMTCLASS=,INFO_DATACLASS=
ZPDA000I INFO_VSAMRECORG=00,INFO_VSAMKEYOFF=0,INFO_COPYDD=,INFO_COPYMDL=
ZPDA000I INFO_AVGRECU=20,INFO_DSTYPE=40,GETHFSPATH,HFS_OPTIONS=0
ZPDA000I HFS_ACCESS=0,HFS_DISP=,HFS_ABDISP=,HFS_ORG=DELIMITED
-INDD(ZIPCUR)
ZPAM030I OUTPUT Archive opened: XXXX.XXXX.XXXX.CSV.ZIP
ZPAM253I ADDED File XXXX.XXXX.XXXX.CSV
ZPAM254I as CSV
ZPAM255I (DEFLATED 95%/95%) DATA SIZE 379,907; ZIP SIZE 20,366
ZPAM140I FILES: ADDED EXCLUDED BYPASSED IN ERROR COPIED
ZPAM140I 1 0 0 0 0
ZPMT002I PKZIP processing complete. RC=00000000 0(Dec)

Hope this provides some Inputs..
Please let me know if anything missing/wrong in this...

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Thu Dec 02, 2010 9:56 am

If you want to verify your zip archive on the target system, take a dump of it and look at it in hex. You should see a specific "PK" header as well as the name of the unzipped file in clear text.

bharani
Member
Posts: 13
Joined: Fri Oct 09, 2009 2:47 am

Post by bharani » Fri Aug 03, 2012 7:57 pm

Dear All,

Am having the same issue now (Stated above). My requirement is also a similar one. I need to zip one file and have to send it as a attachment in email.

Can anyone help me in this? searched a lot, but couldn't find the solution for the same.


Hi Natarajan, If possible can you guide me please? Am successful to send it as an attachment in .txt format. But facing issue here.

Thanks a lot,
Bharani.S

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Aug 03, 2012 9:49 pm

Am successful to send it as an attachment in .txt format. But facing issue here.
What issue? We cannot help much if you do not provide the informaton necessary to help you. . .

Post the jcl, control statements, and diagnostic info (including message ids) frlom the problem run.

You also replied to a dormant topic. It is best to start a new topic when posting a new (even though related) question.
Have a good one

bharani
Member
Posts: 13
Joined: Fri Oct 09, 2009 2:47 am

Post by bharani » Sat Aug 04, 2012 1:57 pm

Thank you DikDude, i have posted a seperate topic on this. Also provided some details on this. Could you please help me on this?

new post : http://www.mainframegurukul.com/ibmmain ... ght=#16641

Thanks,
Bharani.S

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Aug 05, 2012 2:52 am

Thank you for starting a new topic for your question - good job using the Code tags :)

Please see the reply from MrSpock and do this. If there are questions, someone should soon be here.
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others