Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sending images as email attachments

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
marren

New User


Joined: 08 Nov 2013
Posts: 3
Location: india

PostPosted: Mon Nov 11, 2013 12:13 pm    Post subject: Sending images as email attachments
Reply with quote

Hi, I am trying to send pictures as email attachments (In JPEG format). I am getting the attachment but when I am trying to open it using Windows Photo viewer, it says the file is corrupted. I am able to view the same picture without any issues when I am doing an FTP. I came upon a similar topic in http://ibmmainframes.com/viewtopic.php?t=45168&start=0. But couldn't find any resolution. Could anyone please let me know if you have been able to accomplish this.
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Nov 11, 2013 7:23 pm    Post subject:
Reply with quote

Hi,

After some experimentation, One reliable way to send images/PDF/excel files from mainframe was storing the image files in Unix System Services.
I used to route the mainframe output JPEG/GIF/PDF to USS directory & then send the USS file as attachment via a batch job on mainframe.
If your jpeg image is fixed, then FTP the image to USS and email the image from there.

If you have SAS, it is very easy. You can send images,pdf, send twitter tweets, generate reports on google earth, all from mainframe SAS.

Below step, sends an image from USS to your email.
Code:
//STEP1    EXEC SAS
//SYSIN DD *
 FILENAME EMAIL EMAIL
 FROM = ("WELLS@WELLS.COM")
 TO = ("WELLS@WELLS.COM")
 CC = ("WELLS@WELLS.COM")
 REPLYTO=("WELLS@WELLS.COM")
 SUBJECT="SOME SAMPLE TEST REPORT"

 ATTACH=("\USS\filename\here" CT='IMAGE/JPEG' NAME='SOME COOL NAME FOR ATTACHMENT' EXT='JPEG');

DATA _NULL_;
FILE EMAIL;
PUT 'HEY THERE, ATTACHED IS THE JPEG IMAGE';
PUT 'THIS EMAIL WILL SELF DESTRUCT IN 10 SECONDS';
RUN;
/*

Hope it helps.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Mon Nov 11, 2013 7:55 pm    Post subject: Reply to: Sending images as email attachments
Reply with quote

Quote:
I am trying to send pictures as email attachments (In JPEG format). I am getting the attachment but when I am trying to open it using Windows Photo viewer, it says the file is corrupted.
It would be easier to provide some assistance if you had posted the SMTP commands you used, or if you are not using native SMTP commands then at least told us which program you are using to send the email and given us the statements you are using to define the email transmission.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 12, 2013 12:46 am    Post subject:
Reply with quote

After some experimentation, I have discovered that it is possible to convert a GIF file on the mainframe to Base64, then use SMTP to transfer the Base64 data to a PC and have the PC recognize the GIF image. However, as seems typical in my experience with SMTP transfers of non-text data, the process is EXTREMELY sensitive to the precise commands and lines used (even blank lines are required at some spots) -- but it can be done.

marren: since you did not provide much information about your process, hopefully by now you understand that SMTP is a text-only process and that if you want to send a GIF file from the mainframe to any device using SMTP you must first convert the GIF file to Base64 and send the Base64 data instead of the raw GIF file.

The commands I used (with edits to remove critical data):
Code:
//SYSUT1   DD   *
HELO MAINFRAME.xxxxxx.NET
MAIL FROM: <MAINFRAME@xxx.COM>
RCPT TO: <ROBERT.SAMPLE@xxx.COM>
DATA
FROM:     MAINFRAME@xxx.COM
TO:       ROBERT.SAMPLE@xxx.COM
DATE:     NOVEMBER 11, 2013
SUBJECT:  TEST ATTACHMENT
MIME-VERSION: 1.0
CONTENT-TYPE: MULTIPART/MIXED; BOUNDARY="SIMPLE BOUNDARY"
--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN
CONTENT-DISPOSITION: ATTACHMENT; FILENAME=DUCK1.GIF
CONTENT-TRANSFER-ENCODING: BASE64

//         DD   DISP=SHR,DSN=TTSSRS0.DUCK1.ENBASE64
//         DD   *
--SIMPLE BOUNDARY--
.
//
TTSSRS0.DUCK1.ENBASE64 contains the GIF file converted to 80-byte Base64 records. These lines were copied (using IEBGENER) to the SMTP started task on the system; the email showed up with attachment DUCK1.GIF and when the attachment is saved it shows as a GIF.
Back to top
View user's profile Send private message
marren

New User


Joined: 08 Nov 2013
Posts: 3
Location: india

PostPosted: Tue Nov 12, 2013 11:58 am    Post subject: Reply to: Sending images as email attachments
Reply with quote

@Vasanthz,

Thanks a lot for your reply. I will give it a try in a few days since I have some access issues with USS.

@Robert Sample

Thank you very much for the Jcl. I was using the following, without encoding the image.

[/code]
//SYSUT1 DD *
HELO Mainframe
MAIL FROM: <xxx@xxx.com>
RCPT TO: <xxx@xxx.com>
DATA
FROM: <xxx@xxx.com>
TO: <xxx@xxx.com>
Subject: TEST
MIME-VERSION: 1.0
CONTENT-TYPE:MULTIPART/MIXED;BOUNDARY="SIMPLE BOUNDARY"

--SIMPLE BOUNDARY
CONTENT-TYPE: TEXT/PLAIN

Image attached

--SIMPLE BOUNDARY
CONTENT-TYPE: IMAGE/JPEG;
CONTENT-DISPOSITION:ATTACHMENT; FILENAME=IMAGE.JPEG

// DD DISP=SHR,DSN=xxx.image
// DD *
--SIMPLE BOUNDARY--
.
//
[/code]

Hopefully now I will be able to do it after encoding as you have suggested. Thanks again.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7914
Location: Bellevue, IA

PostPosted: Tue Nov 12, 2013 5:09 pm    Post subject:
Reply with quote

Yes, SMTP will not properly handle the raw JPEG data so your image would be corrupted. The same goes for ZIP, GIF, PNG, PDF or any other binary-based data.
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 73
Location: Boston

PostPosted: Tue Nov 19, 2013 6:06 pm    Post subject:
Reply with quote

I was not very successful trying to convert a JPG file to Base64 for a similar requirement to email via SMTP icon_sad.gif

But a slight modification of vasanthz's SAS step worked for me to email JPG and PDF files stored as binary on the mainframe.

Please try the below step

Code:

//*---------------------------------------------------------------------
//STEP1    EXEC SAS                                                     
//SYSIN DD *                                                           
 FILENAME EMAIL EMAIL                                                   
 FROM = ("XXX@XXX.COM")                                             
 TO = ("XXX@XXX.COM")                                               
 CC = ("XXX@XXX.COM")                                               
 REPLYTO=("XXX@XXX.COM")                                           
 SUBJECT="SOME SAMPLE TEST REPORT"                                     
 ATTACH=("MF File name" NAME='TEST FILE1' EXT='JPG');           
 DATA _NULL_;                                                           
 FILE EMAIL;                                                           
 PUT 'EMAIL ENDS HERE ';                                             
 RUN;                                                                   
/*                                                                     



Thanks,
Ashwin.
Back to top
View user's profile Send private message
marren

New User


Joined: 08 Nov 2013
Posts: 3
Location: india

PostPosted: Fri Nov 29, 2013 3:27 pm    Post subject:
Reply with quote

Thank you very much Ashwin. You have made my job a lot easier. It worked perfectly.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts Reading data from PS file and send it... rajatbagga All Other Mainframe Topics 18 Fri Sep 23, 2016 12:51 pm
No new posts How to sending system service request... lind sh IMS DB/DC 5 Sun Apr 10, 2016 12:02 am
No new posts How to send email with Rich Text usin... santhosh5983 JCL & VSAM 4 Fri Apr 08, 2016 2:30 am
No new posts Issue in sending zip file as mail att... ajithajt JCL & VSAM 8 Thu Apr 07, 2016 9:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us