Multiple Attachments in Email



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Multiple Attachments in Email

Postby phow0906 » Thu Sep 23, 2010 12:42 am

Can someone give me some sample code of attaching multiple attachments to an email using SMTP? We currently have an application sending one attachments but haven't had any luck sending multiple attachments. My code is concatenating them and I do not want that. They need to be separate attachments and are reports created on the mainframe. Thanks!
phow0906
 
Posts: 9
Joined: Wed Sep 22, 2010 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiple Attachments in Email

Postby Robert Sample » Thu Sep 23, 2010 12:50 am

My experience is that sending multiple attachments is very sensitive to syntax and alignment. Changing as little as one character of the below code has caused failures ranging from attachments being placed inline to no email being sent. Also note that sending non-text attachments does not work well unless there is only one attachment. Some experimentation may be required at your site to get the precise format that works.
HELO  computer.name
MAIL FROM: <sender@xxx.COM>
RCPT TO:   <recipient@xxx.COM>
DATA
SUBJECT: subject title for email
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"

--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=TEST1.TXT

//    DD  DISP=SHR,DSN=attachment.one.dsn
//    DD  *
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=TEST2.TXT

//    DD  DISP=SHR,DSN=attachment.two.dsn
//    DD  DISP=SHR,DSN=trailing period.dsn
//
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Multiple Attachments in Email

Postby phow0906 » Thu Sep 23, 2010 1:09 am

Thank you so much for your prompt reply. The construc sends it correctly and gives the name of the text attachment. But it concatenates the 2 different files. But from my code I can see why but don't know how to do it differently. Do not need to send 2 emails but one email with 2 attachements. My code....
//IDCAMS08 EXEC PGM=IDCAMS
//*
//IF1 DD *
HELO JOBTRAC
MAIL FROM:<ABC@ANYWHERE.ORG>
RCPT TO:<XYZ@ANYWHERE.ORG>
DATA
FROM:ABC
TO: XYZ@ANYWHERE.ORG
SUBJECT: REPORTS
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED;CHARSET=US-ASCII
CONTENT-DISPOSITION: ATTACHMENT; FILENAME="REPORT.TXT"
/*
//*
//OF1 DD DSN=WS.TDOC.ACS.EMAIL.CONSTRUC,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(200,(1,1),RLSE),AVGREC=K,
// RECFM=VB,LRECL=200
//*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
REPRO INFILE(IF1) OUTFILE(OF1)
//*
//*-------------------------------------------------------------------
//* SEND REPORTS EMAIL
//*-------------------------------------------------------------------
//*
//IEBGEN09 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=WS.TDOC.ACS.EMAIL.CONSTRUC,
// DISP=SHR
// DD DSN=WS.TSTW.ACS.COA.REPORT,
// DISP=SHR
// DD DSN=WS.TSTW.ACS.NIXIE.REPORT,
// DISP=SHR
//SYSUT2 DD SYSOUT=(9,SMTP)
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
phow0906
 
Posts: 9
Joined: Wed Sep 22, 2010 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiple Attachments in Email

Postby Robert Sample » Thu Sep 23, 2010 1:24 am

When I submit the code I posted, I get a single email with two attachments. Each contains only the data specified -- no concatenation occurs.

Did you even look at my code? You are explicitly telling SMTP to send a single attachment with everything concatenated with these statements:
CONTENT-TYPE: MULTIPART/MIXED;CHARSET=US-ASCII
CONTENT-DISPOSITION: ATTACHMENT; FILENAME="REPORT.TXT"
If you don't use a BOUNDARY, you don't get a boundary -- and without a boundary, you are not sending multiple attachments, you are sending one single attachment. And the blank lines in my code are not optional -- I don't know why they are required, but if they are not there you either get a single attachment or no email.

Do a test -- copy the code I posted, change the input data files and addresses, then submit it exactly as entered. If you get two attachments in one email, then you can proceed. If you do not, you need to work with your site support group to figure out the issue since I have tested -- TODAY -- the posted code and know that it works under SMTP to send one email with two attachments.

If you insist on doing your own thing and not follow advice posted, why are you even asking on this forum for help?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Multiple Attachments in Email

Postby phow0906 » Thu Sep 23, 2010 1:32 am

I'm sorry but your message seems to but truncated. I am new to this forum and must not be viewing the responses correctly or something.
phow0906
 
Posts: 9
Joined: Wed Sep 22, 2010 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiple Attachments in Email

Postby dick scherrer » Thu Sep 23, 2010 1:48 am

Hello and welcome to the forum,

Why do you believe there is truncation? Can you post an example?

Everything i see appears correct. All of the text seems complete and ends with proper punctuation.

If you have a small screen and some unique browser setup, the appearance may not be as you would want. . .
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: Multiple Attachments in Email

Postby phow0906 » Thu Sep 23, 2010 1:56 am

I finally got your entire code. But something is wrong with " DD DISP=SHR,DSN=trailing period.dsn". I don't have a file named that. Plus I had to put a dot in between the trailing and period words as it gave an error without it. Not sure what that code is?
phow0906
 
Posts: 9
Joined: Wed Sep 22, 2010 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiple Attachments in Email

Postby dick scherrer » Thu Sep 23, 2010 2:08 am

Hello,

Plus I had to put a dot in between the trailing and period words as it gave an error without it.
There was no intent to provide executable JCL . . . :(

What was provided was a complete example that YOU needed to change to your specifics and follow the syntax rules for JCL. . . .

Not sure what that code is?
What code? There must be a dataset that contains a single period as the data in the file. This would be the "trailing period dataset".
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: Multiple Attachments in Email

Postby phow0906 » Thu Sep 23, 2010 2:14 am

I understand now that I have to create the DSN for that trailing period and that was code I was talking about. I don't understand why that is needed but guess I don't need to know that. Still getting error but much closer than I was and I am actually understanding this code now. Thank you so much for all your help!!!
phow0906
 
Posts: 9
Joined: Wed Sep 22, 2010 11:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Multiple Attachments in Email

Postby Robert Sample » Thu Sep 23, 2010 2:33 am

RFC 2821 (which you can Google) defines what an SMTP email consists of. Section 4.1.1.4 specifically states that the DATA portion of the email is terminated by a line with a period and nothing else on it. That is why it is needed -- the standard requires it, or the email is not an email and will be discarded by the SMTP task on the mainframe.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post