0

Requirement: To send VB file of records length 100 as attachment using TCPSMTP utility with proper message in body without using IEBGENER utility.

I am trying to send email attachment file VB dataset as attachment. Its working either message in attachment or attachment file in body. But both simultaneously not working. My JCL is:

    //IRTCPN15 EXEC  PROC=TCPSMTP                               
    //SMTPIN   DD  DSN=EMAIL.CODE,                       
    //             DISP=SHR                                      
    //         DD  DSN=FILE.TOBE.SENTAS.ATTACH.MENT,DISP=SHR

Here, I have used both datasets EMAIL.CODE and FILE.TOBE.SENTAS.ATTACH.MENT of same specification VB 100 record length. I have also tried using boundary demiliter, but still its not working both together.

Dataset EMAIL.CODE contains:

    HELO *******                                                            
    MAIL FROM:<*******>                                                  
    RCPT TO: <********>;                                                                                
    DATA                                                                      
    FROM:    <******>                                               
    TO:      <*******>;                                                                              
    SUBJECT: subject data 
    MIME-VERSION: 1.0                                                         
    CONTENT-TYPE: TEXT/PLAIN                                                   
        ---Mail Body---                        
    CONTENT DISPOSITION: ATTACHMENT; FILENAME=FILE.TXT

Please suggest me how to send this attachment with body. I have used asterisk due to security reasons. Please feel free to ask if any more information is needed.

deepaklearner
  • 151
  • 1
  • 6
  • 22

1 Answers1

1

In the EMAIL.CODE dataset, you're specifying that content-type of your message is text/plain. However, text/plain on its own (which is the default content type anyway) is always going to appear inline.

In order for the text in the message to be seen as an attachment, you need a Content-Disposition header that specifies attachment.

I can see in your question that you have a CONTENT DISPOSITION line, but it's labeled as being part of the message body. In addition to the fact that it needs to be a header, not a part of the body, it also needs to be hyphenated. So you should have CONTENT-DISPOSITION, not CONTENT DISPOSITION.

However, what all of this gets you is a message containing nothing but the attachment, and your question specifies that you want both a message body and an attachment. In order to do that, your Content-type at the top level needs to be multipart/mixed, and the body of the message needs to contain two MIME parts, one specified simply as being text/plain, and the other also text/plain, but with Content-Disposition: attachment.

This example shows the data for a MIME message containing both a text/plain body and a text/plain attachment.

FROM: <sender@example.com>
TO: <receiver@example.com>
Subject: TESTING message with body and attachment.
Mime-Version: 1.0
Content-type: multipart/mixed; boundary=MIME_BOUNDARY

This is the non-MIME body of a multipart message in MIME format.
Unless you are using a genuinely ancient email client or viewing
the raw source of a message, you should never see this paragraph.

--MIME_BOUNDARY
Content-type: text/plain

This is the inline text section of a multipart message
in MIME format. This is what will appear as the body
of your email when using any normal email client.

--MIME_BOUNDARY
Content-type: text/plain
Content-Disposition: attachment; filename=example.txt

This is the plain-text attachment.
--MIME_BOUNDARY--
.
This isn't my real name
  • 4,869
  • 3
  • 17
  • 30