Highlighted
Absent Member.
Absent Member.
3477 views

[archive] email attachments

[Migrated content. Thread originally posted on 11 June 2004]

Hello Everyone,

I have been looking into how we can code our COBOL system to send emails. I have looked at the various options and decided that the C$SOCKET solution that links directly to the SMTP port (25) is the best solution. (See example program sendmail.cbl). Reason being we need to run our system on both windows and unix platforms.

I have got this program working in our test environment and we will encorporate the code into our programs accordingly.

However, it does not show how we can email binary attachments such as word or pdf documents.

I am lead to believe that the binary files will need to be encoded into ASCII format and sent accordingly. Is this the case? If so how is it done and what is the syntax required to send it? Has anyone else managed to send attachments at all?

Please Help me as I am now stuck on where we go from here.

Regards
Brian
0 Likes
15 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

A standard e-mail consists only of ASCII characters.

To add binary attachments, you need to use MIME (Multipurpose Internet Mail Extensions). MIME is a standard that describes how to specify the attachments in the body of the e-mail.

The attachment itself can be in various formats. For example, if you want to send an e-mail formatted using HTML, it is really sent as a MIME attachment, specifying that it is in the HTML format.

To send binary files, you have to "encode" the files so that the file can be represented entirely as ASCII text. One of the most common ways to do this is base64.

See this page for a brief overview:

http://www.dpo.uab.edu/Email/attach.html

See the RFC for a more detailed explanation:

http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1521.html

As for encoding a binary file into base64 in Cobol, well... I've never seen any example code doing that. But there are third party ActiveX and DLL components that will do all of the e-mail handling for you, including attachments.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Thanks for providing this useful information and the links.

As for the encoding of the attachments, I would suggest that one may use one of the freeware uuencode/uudecode programs. I know these are available on most platforms.

It should also be possible to get a hold of example code for this, of course in C, but still. Could have been an interesting project, to create an uu(en)(de)code parser in COBOL.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Hello gisle,

i've written a subroutine to send emails, based on the sendmail.cbl. This subrotuine can compose and send a email including up to three attachment-files. The attatchments will be encoded with base64. The whole subroutine is written in COBOL. Detailed description is available.

Originally posted by gforseth
Thanks for providing this useful information and the links.

As for the encoding of the attachments, I would suggest that one may use one of the freeware uuencode/uudecode programs. I know these are available on most platforms.

It should also be possible to get a hold of example code for this, of course in C, but still. Could have been an interesting project, to create an uu(en)(de)code parser in COBOL.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Firstly I would like to take this opportunity to thank JOED for his information above.

We have managed to work out how to send binary attachments from our system using the original code within sendmail.cbl and also the information posted by JOED.

However, to encrypt binary files to mime-64 I was going to use a freeware product called "uudeview" which we were going to call using C$SYSTEM.

The problem with that though is we need to compile it on different Unix platforms which I have not yet done as our customer needs it on a windows platform.

Therefore if we can do it all in COBOL it would be a much better solution for us.

Theefore, please, please, please Peter can you provide us your example source code that converts the binary file into MIME-64 format.

Regards
Brian Douglas
bd@interchangegroup.com
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Hi This is also exactly what We are also looking, the sendmail
works very well, if it could do an attachment it would be wonderfull, could one of you kind people please post an example
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Ditto - would be keen to see Peter's example cose for sending emails with attachments as I will be wanring to do this myself very soon.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Hi,

cou can find the example for sending Emails with attachments on the following webpage:

http://www.kiss-personal.de/cobolmail.htm

on this page you will find the sample source code and the lecture hold on the 15th AcuCorp Developer Conference in Munich.
(language: german). A short description in English is also available on this website.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

There's a product at marshallsoft.com that will allow you to incorporate every Email feature into a cobol application. It's inexpensive and very easy to use. Saved me a lot of hassles.

Regards

Vins Nash
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Hi Fans,

I've tested this product from Marshallsoft.com. This product is not freeware like the cobol-program descrobed on my website.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Hey peter, just downloaded and tested the program you said!
Great work!! I will try to create my own now based on that!
You really saved me (and i am sure many others) a lot of frustration.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] email attachments

Peter - looked at the website you mentioned but seems to have acubench sample - as I do not user this it is difficult to get to look at the sample source. Any chance of just a simple listing of the generated cobol program?
Keith
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.