View previous topic :: View next topic
|
Author |
Message |
marren
New User
Joined: 08 Nov 2013 Posts: 3 Location: india
|
|
|
|
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 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 |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1745 Location: Tirupur, India
|
|
|
|
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 |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
 |
marren
New User
Joined: 08 Nov 2013 Posts: 3 Location: india
|
|
|
|
@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 |
|
 |
Robert Sample
Global Moderator

Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
 |
hailashwin
New User

Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
I was not very successful trying to convert a JPG file to Base64 for a similar requirement to email via SMTP
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 |
|
 |
marren
New User
Joined: 08 Nov 2013 Posts: 3 Location: india
|
|
|
|
Thank you very much Ashwin. You have made my job a lot easier. It worked perfectly. |
|
Back to top |
|
 |
|