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

Sending an email attachment via JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chhabraravneet

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Wed May 30, 2012 12:07 am
Reply with quote

Hi,
Trying to execute the below code, but i am not getting any attachment. Instead, what i am trying to attach is coming in email body itself.
Plese help:

//PWSTEP03 EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD SYSOUT=(B,SMTPT)
//SYSUT1 DD DISP=SHR,DSN=USSERID.TEST.EMAIL1
// DD DISP=SHR,DSN=USERID.TEST.EMAIL
//
/*

USSERID.TEST.EMAIL1 consists of:

HELO JOBTRAC
MAIL FROM:<XYZ@XYZ.COM>
RCPT TO :XYZ@XYZ.COM
DATA
FROM: XYZ@XYZ.COM
TO: XYZ@XYZ.COM
SUBJECT: JOB COMPLETED (SEE ATTACHMENT)
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME="XYZZ.TXT"


USERID.TEST.EMAIL consits of the attachment.

Both the files have same DCB parametres.

thanks for the help.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 30, 2012 12:37 am
Reply with quote

start with the links provided in this thread

if that does not answer your question, you can always search the jcl forum with a search key of: email + attachement
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: Wed May 30, 2012 2:51 am
Reply with quote

Hello,

You have included the "attachment" as part of the actual e-mail text. . .
Back to top
View user's profile Send private message
chhabraravneet

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Wed May 30, 2012 6:36 pm
Reply with quote

Thanks Dick.

Then how to include the attachment..i dont want to include it in email text..

Regards,
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 30, 2012 6:50 pm
Reply with quote

dbzTHEdinosauer wrote:
start with the links provided in this thread

if that does not answer your question, you can always search the jcl forum with a search key of: email + attachement


i re-quote my earlier comment, since you seem to have missed it,
since i directly do not provide the control cards you need,
and you obviously have to dig for the answer yourself.

or, do you feel that we should just waste space repeating
what has be posted in other forums
and/or
what the manual/documentation provides?

am i missing something here?
Back to top
View user's profile Send private message
chhabraravneet

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Wed May 30, 2012 6:59 pm
Reply with quote

Hi Dick Brenholtz ,

Obviously you guys should not waste time in repeating the stuff and positng it again and again.

But i read your column and the chains that you provided. I did everything included the simple boundaries...changed my MIME command..but its not working. Moreover the threads that you provided too are not enough..as in that thread ultimately people are stuck with the same thing (not able to attach in emai) or they have been told to contact the email support group of their site.

As of now im stuck with this...and studing MIME...and trying to write/find the exact jcl code...
Back to top
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Wed May 30, 2012 7:23 pm
Reply with quote

Tried from the suggested link. This works.

Code:
//STEP010  EXEC PGM=IEBGENER
//SYSIN    DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2   DD SYSOUT=B,DEST=SMTP
//SYSUT1   DD *
HELO JESNDIXA
MAIL FROM:<from-mail-id>
RCPT TO:<to-mail-id>
DATA
FROM: MAINFRAME
TO: to-mail-id
SUBJECT: TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT
//         DD DISP=SHR,DSN=user-id.TEST.JCL(EMAILATT)
//         DD DISP=OLD,DSN=user-id.TEST.JCL(EMAILAT)
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed May 30, 2012 7:41 pm
Reply with quote

ibmmainframes.com/viewtopic.php?t=55814&highlight=email
ibmmainframes.com/viewtopic.php?t=57288&highlight=email
ibmmainframes.com/viewtopic.php?t=31751&highlight=email
ibmmainframes.com/viewtopic.php?t=50277&highlight=email
ibmmainframes.com/viewtopic.php?t=50150&highlight=email
ibmmainframes.com/viewtopic.php?t=48292&highlight=email
ibmmainframes.com/viewtopic.php?t=48602&highlight=email
ibmmainframes.com/viewtopic.php?t=47548&highlight=email
ibmmainframes.com/viewtopic.php?t=47397&highlight=email
ibmmainframes.com/viewtopic.php?t=47371&highlight=email
ibmmainframes.com/viewtopic.php?t=45383&highlight=email
Back to top
View user's profile Send private message
chhabraravneet

New User


Joined: 04 Oct 2007
Posts: 49
Location: Mumbai

PostPosted: Wed May 30, 2012 8:55 pm
Reply with quote

Thanks a lot guys...for all your inputs...

i got it and it worked...

the last issue that i was facing was..my attachment file was coming from a sysprint..so if was always VBA and getting its own record length..
so i changed my control card to the same parametres as that of the attachment file that i was creating from the sysprint..ie kept all as VBA, same record lenght and same block size..and it worked..

thank you once again....
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: Wed May 30, 2012 10:18 pm
Reply with quote

You're welcome - and thank you for the followup explaining your solution icon_smile.gif

d
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Wed Jun 06, 2012 8:46 pm
Reply with quote

I'm seem to be getting an issue not covered off in any of the other posts. I can send a text e-mail fine, an e-mail with an attachment fine, and an e-mail with both...up to a point.

What happens when I try and send text in the e-mail plus an attachment is that I lose all the line breaks in the body text so the resultant e-mail is just one line.

Any ideas? Are any special control characters required? The MIME docs that I have read talk about CRLF to start a new line which is x'0D0A' in ASCII but I don't know what would be required on the mainframe.
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Tue Jun 12, 2012 7:11 pm
Reply with quote

Further reading tells me that x'0A' in ASCII maps to x'25' in EBCDIC, so that implies that x'0D25' should do the trick, but it's still no good.

I've tried every combination of x'0A', x'0D' and x'25' that I can think of, without any success.

Any suggestions?
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 12, 2012 7:36 pm
Reply with quote

From RFC 2821:
Quote:
2.3.7 Lines

SMTP commands and, unless altered by a service extension, message
data, are transmitted in "lines". Lines consist of zero or more data
characters terminated by the sequence ASCII character "CR" (hex value
0D) followed immediately by ASCII character "LF" (hex value 0A).
This termination sequence is denoted as <CRLF> in this document.
Conforming implementations MUST NOT recognize or generate any other
character or character sequence as a line terminator. Limits MAY be
imposed on line lengths by servers (see section 4.5.3).

In addition, the appearance of "bare" "CR" or "LF" characters in text
(i.e., either without the other) has a long history of causing
problems in mail implementations and applications that use the mail
system as a tool. SMTP client implementations MUST NOT transmit
these characters except when they are intended as line terminators
and then MUST, as indicated above, transmit them only as a <CRLF>
sequence.
In other words, unless your mail client supports use of some specific character sequence to work as a line termination sequence, you cannot specify line terminators in an email. I haven't researched what the "service extension" could be -- and even if that has an answer to your problem, you'd have to worry about every link in the message handling that service extension the same way.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Jun 12, 2012 7:39 pm
Reply with quote

David - have you had a chance to look at this thread: ibmmainframes.com/viewtopic.php?t=50277&highlight=email

Also, suggest you please show us the JCL you've used. SMTP with MIME gets very picky about syntax at times.
Back to top
View user's profile Send private message
David Robinson

Active User


Joined: 21 Dec 2011
Posts: 199
Location: UK

PostPosted: Wed Jun 13, 2012 7:16 pm
Reply with quote

I have managed to resolve this now, and it was nothing to do with having a <CRLF> string. As others have said, MIME is very sensitive to positions, blank lines, etc., and although my original job was identical to an example posted here, for some reason it didn't work.

I've just tried various other examples on a trial and error basis and found one that worked fine (thanks to Robert's JCL on the link that Anuj provided).

Many thanks to everyone for your help and suggestions.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Jun 13, 2012 7:50 pm
Reply with quote

Thanks for the feedback. Yes, Robert is one of the excellent contributors on this board.
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 -> JCL & VSAM

 


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 How to append Previous date into a S... JCL & VSAM 2
Search our Forums:

Back to Top