SMTP/POP3/IMAP Email Engine
Library for COBOL
Programmer's Manual
(SEE4CB)
Version 5.2
May 4, 2010
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 2010
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Email: info@marshallsoft.com
Web: www.marshallsoft.com
MARSHALLSOFT is a registered trademark of MarshallSoft Computing.
1 Introduction
1.1 Features2 Library Overview
1.2 Documentation Set
1.3 Example Program
1.4 Installation
1.5 Uninstalling
1.6 Pricing
1.7 Updates
2.1 Dynamic Link Libraries3 Compiler Issues
2.2 Keycode
2.3 Win32 STDCALL and DECLSPEC
2.4 Error Display
3.1 Versions of Win32 COBOL4 Example Programs
3.2 Compiling Fujitsu COBOL Programs
3.3 Compiling Micro Focus COBOL Programs
3.4 Other Win32 COBOL Programming Languages
4.1 Connectionless Example Programs5 Revision History
4.2 SMTP Example Programs
4.3 POP3/IMAP Example Programs
4.4 IMAP-Only Example Programs
The SMTP/POP3/IMAP Email Engine for COBOL (SEE4CB) library is a toolkit that allows software developers to quickly develop SMTP and POP3/IMAP email applications in COBOL.
The SMTP/POP3/IMAP Email Engine (SEE) is a component library of functions providing direct and simple control of the SMTP (Simple Mail Transport Protocol), POP3 (Post Office 3), and IMAP 4 (Internet Message Access Protocol) protocols.
A straightforward interface allows sending, receiving and parsing email, including multiple MIME base64 and quoted-printable encoded attachments, over any TCP/IP network (such as the Internet). Knowledge of Winsock and TCP/IP is not needed.
The SMTP/POP3/IMAP Programmer's Manual provides information needed to compile and run programs in a COBOL programming environment.
The SMTP/POP3/IMAP Email Engine for COBOL component library works with Win 32 Fujitsu COBOL and any other COBOL (such as Micro Focus COBOL) capable of calling the Windows Win32 API. SEE4CB includes numerous example programs that demonstrate SMTP and POP3/IMAP functions used to build mail applications using the SEE4CB library.
A Win32 DLL (Dynamic Link Library) is provided. SEE4CB runs under all versions of Windows (Windows 95, Windows 98, Windows ME, Windows 2000, Windows 2003, Windows NT, Windows XP, Windows Vista and Windows 7). A Win64 DLL is available for Win64 programming languages. The SMTP/POP3/IMAP Email Engine SDK DLLs (SEE32.DLL or SEE64.DLL) can also be used from any language (C/C++, .NET, Visual Basic, VB. NET, VBA, Delphi, Visual FoxPro, PowerBASIC, Xbase++, dBase, etc.) capable of calling the Windows API.
When comparing SMTP/POP3/IMAP Email component library against our competition, note that:
MarshallSoft also has versions of the SMTP/POP3/IMAP Email Engine library for C/C++ (SEE4C), Visual Basic (SEE4VB), Delphi (SEE4D), PowerBASIC (SEE4PB), Visual FoxPro (SEE4FP), Visual dBASE (SEE4DB), and Xbase++ (SEE4XB). All versions of the SEE library use the same DLLs (SEE32.DLL or SEE64.DLL). However, the examples provided for each version are written for the specified computer programming language.
The latest versions of SMTP/POP3/IMAP Email Engine (SEE) can be downloaded from our web site at
http://www.marshallsoft.com/email-component-library.htm
Our goal is to provide a robust SMTP/POP3/IMAP email component library that you and your customers can depend upon. A fully functional evaluation version is available. Contact us if you have any questions.
Some of the many features of the SMTP/POP3/IMAP Email Engine component library are as follows:
Registration includes one year of free updates and technical support.
The complete set of documentation consists of three manuals in Adobe PDF format. This is the first manual (SEE_4CB) in the set.
The SEE_4CB Programmer's Manual is the language specific (COBOL) manual. All COBOL programming issues such as compiling, compilers and example programs are discussed in this manual. Read this manual first.
The SEE User's Manual (SEE_USR) discusses email processing as well as language independent programming issues. Purchasing and license details are also provided.
The SEE Reference Manual (SEE_REF) contains details on each individual SEE function.
The online documentation can be accessed on the SMTP/POP3/IMAP Email Engine for COBOL product page at:
http://www.marshallsoft.com/see4cb.htm
The following example demonstrates the use of some of the SMTP/POP3/IMAP Email for COBOL component library functions:
*> attach SEE
CALL "seeAttach" WITH STDCALL USING
BY VALUE NBR-CHANS *> number of channels
BY VALUE SEE-KEY-CODE *> See KEYCODE.CBI
END-CALL.
*> connect to SMTP server
DISPLAY "Calling seeConnectTo()..."
CALL "seeConnectTo" WITH STDCALL USING
BY VALUE IS-ZERO *> channel
BY REFERENCE SMTP-SERVER *> SMTP server
BY REFERENCE EMAIL-FROM *> sender's email address
BY REFERENCE IS-ZERO *> no Reply-To header
END-CALL.
*> send email
DISPLAY "Calling seeSendEmail()..."
CALL "seeSendEmail" WITH STDCALL USING
BY VALUE IS-ZERO *> channel
BY REFERENCE EMAIL-TO *> recipient
BY REFERENCE IS-ZERO *> no CC list
BY REFERENCE IS-ZERO *> no BCC list
BY REFERENCE EMAIL-SUBJ *> email subject
BY REFERENCE EMAIL-MSG *> text of message
BY REFERENCE IS-ZERO *> no attachment
END-CALL.
*> close and release SEE
CALL "seeClose" WITH STDCALL USING
BY VALUE IS-ZERO *> channel
END-CALL.
CALL "seeRelease" WITH STDCALL
END-CALL.
In the example program above, seeAttach is called to initialize SEE and then seeSmtpConnect is called to connect to the SMTP mail host. The SMTP server host name and your email address are required, while the "Reply-To" entry is optional.
seeSendEmail is then called, passing the addressee lists. The primary addressee is provided in the "To List". The CC ("Carbon Copy") lists additional recipients, as does the BCC (Blind Carbon Copy) list. The subject contains the email subject line. The message text is next. If it starts with the '@' symbol, it is considered the name of the file containing the email message. Lastly, the filename of any ASCII or binary attachment is specified. All fields, except the first, in seeSendEmail are optional.
After returning from seeSendEmail, the seeClose function is called to close the connection to the SMTP server. Lastly, seeRelease is called to perform SEE termination processing and release the Winsock.
Note that the Windows registry is not modified.
Uninstalling SEE4CB is very easy. SEE does not modify the registry.
First, run UINSTALL.BAT, which will delete SEE32.DLL from your Windows directory, typically C:\WINDOWS for Windows 95/98//2003/Me/XP/Vista/Win7 or C:\WINNT for Windows NT/2000.
Second, delete the SEE project directory created when installing SEE4CB.
A developer license for SEE4CB can be purchased for $115. Purchasing details can be found in Section_1.4 "How to Purchase" in the SEE User's Manual (SEE_USR.HTM). Also see INVOICE.TXT provided with the evaluation version or order directly on our web site at
http://www.marshallsoft.com/order.htm
Registration includes one year of free updates.
When a developer license is purchased, you will be sent a set of registered DLLs plus a license file (SEExxxx.LIC, where xxxx is your Customer ID). The license file can be used to update the registered DLL's for a period of one year from purchase. Updates can be downloaded from
http://www.marshallsoft.com/update.htm
After one year, your license must be updated if you want to be able to download updates.
The license can be updated for $30 if ordered within one year of the original purchase (or
previous update). Between one year and three years, licenses can be updated for $55.
After three years, a license can be updated for $75.
Note that the registered DLL's do not expire; however, the ability to download version updates expires after one year. Refer to the file UPDATES.TXT located in the /SEE4CB/DOCS directory for more information.
The SMTP/POP3/IMAP Email component library has been tested on multiple computers running Windows 95/98/Me/XP/2003/Vista/Windows 7 and Windows NT/2000.
The SEE4CB library has been tested with Fujitsu COBOL and also works with Micro Focus COBOL
The SETUP installation program will copy the SEE32.DLL to the Windows directory and copies the SEE4CB files to the directory specified (default \SEE4CB). Three sub-directories are created, as follows:
DOCS - All documentation files
APPS - All example code
DLLS - All DLL's
The SMTP/POP3/IMAP Email component library includes both Win16 and a Win32 dynamic link library (DLL). A DLL is characterized by the fact that it need not be loaded until required by an application program and that only one copy of the DLL is necessary regardless of the number of application programs that use it. Contrast this to the traditional static library that is bound to each and every application that uses it at link time.
An important advantage that DLL's have over other "popular" library formats such as VBX or OCX is that DLL's are callable by all Windows applications. Since DLL's are the building blocks of the Windows Operating System, they will not be replaced by a "newer technology".
The SEE32.DLL has a keycode encoded within it. Your keycode is a 9 or 10 digit decimal number (unless it is 0), and will be found in the file KEYCODE.CC. The keycode for the evaluation (shareware) version is 0. You will receive a new keycode and a set of new DLL's when registering. The KEYCODE is passed to SeeAttach.
If you get an error message (value -74) when calling SeeAttach, it means that the keycode in your application does not match the keycode in the DLL. After registering, it is best to remove the evaluation version of the SEE32.DLL and SEE16.DLL from the Windows search path or delete them.
SEE32 is written in ANSI C and is compiled using the _stdcall and _declspec keywords. This means that SEE4CB uses the same calling conventions and file naming conventions as the Win32 API. In particular, function names are NOT decorated. There are neither leading underscores nor trailing "@size" strings added to function names.
The SEE32.DLL functions may be called by any Windows application program capable of calling the Windows API provided the proper declaration file is used.
The error message text associated with SEE error codes can be displayed by calling seeErrorText. Each sample program contains examples of error processing.
Also see the file seeErrors.txt for a list of all Winsock and SEE error codes.
The email functions in SEE32.DLL can be called from any program which is capable of calling the Windows Win32 API. In order to call the email functions, the proper syntax for calling external Windows DLL's must be used. Unfortunately, this syntax is different for each COBOL compiler.
For Fujitsu, the function interface file is SEE32.CBI. For Micro Focus, the interface file is SEE32.MFI.
The Fujitsu COBOL Project Manager is used to compile and link the example programs. When linking, remember to include SEE32.LIB in the list of files to link.
Alternatively, the FCL.BAT file can be used to invoke the Fujitsu compiler and linker from the command line. Be sure to copy COBOL.CBI from the Fujitsu COBOL97 directory to the directory which contains the example programs.
FCL AUTHEN
FCL BCAST
FCL GETRAW
FCL HTML
FCL MAILER
FCL MAILER2
FCL READER
FCL READER2
FCL SEEVER
FCL STATUS
FCL MPARTS
FCL FORWARD
FCL POP3RD
FCL GmailMVP
We do not have Micro Focus COBOL, although we have many customers who use SEE4CB with it.
In order to compile for MicroFocus COBOL, examine the Micro Focus version of the SEEVER program (SEEVERMF.CBL). If you would like the complete example set for MicroFocus COBOL, send an email to support@marshallsoft.com, and we will be glad to send it to you.
If you develop an interface file for other COBOL languages, we would really appreciate a copy. Email the interface file, along with any example programs that you have converted, to support@marshallsoft.com.
If you are programming in another Win32 COBOL language, we may already have the necessary interface file. Let use know which COBOL you want to use.
Each example program, with the exception of SERVER.CBL, must be edited with your email parameters before compiling. For example, to change the "mail.hiwaay.net" below to "mail.mine.com", the following changes must be made:
000360 01 SMTP-SERVER.
000370 05 FILLER PIC X(15) VALUE "mail.hiwaay.net".
000380 05 FILLER PIC X VALUE X'00'.
to
000360 01 SMTP-SERVER.
000370 05 FILLER PIC X(13) VALUE "mail.mine.net".
000380 05 FILLER PIC X VALUE X'00'.
Note that the length was changed from 15 characters to 13 to accommodate the shorter server name.
Before writing your own programs, compile and run several of the example programs. SMTP programs send email. POP3 programs read email.
The SEEVER example program does not require a connection to an SMTP server.
The first example program SEEVER displays the SEE library version number and registration string. It does not require a connection. See SEEVER.CBL for Fujitsu or SEEVERMF.CBL for MicroFocus.
Compile and run SEEVER first. It will verify that SEE32.DLL can be found at runtime and that your keycode is specified correctly.
There are eight SMTP email example programs. SMTP programs send email.
AUTHEN is an example program that connects to an SMTP server using SMTP Authentication. You must connect to a SMTP server which allows authentication.
AUTHEN.CBL must be edited with your email parameters before compiling.
The BCAST example program emails the same message (BCAST.TXT) to a list of addresses taken from the file, BCAST.EML, containing one email address per line. Along with the SMTP server and your email address, the file containing the email message to send must be created along with another file containing the list of recipients. See EMAIL.LST for an example.
BCAST.CBL must be edited with your email parameters before compiling.
The HTML example program connects to an SMTP server and emails an HTML file (HTML.MAI) containing inline graphics (IMAGE1.GIF and IMAGE2.GIF). The graphics files are attached to the HTML email message.
HTML.CBL must be edited with your email parameters before compiling.
The MAILER example program emails a message, including an optional MIME attachment. The MAILER.CBL program must be edited with your email parameters before compiling. Note that <> brackets are required around all email addresses.
MAILER.CBL must be edited with your email parameters before compiling.
The MAILER2 example program operates like MAILER, except that it runs in direct mode rather than indirect mode like MAILER.CBL. The primary use of direct mode is to return control to the calling application code as the email is being sent for the purpose of displaying progress. See the SMTP/POP3/IMAP User's Manual (SEE_USR) for details on direct mode.
The MAILER2.CBL example program must be edited with your email parameters before compiling.
The ISO8859 example program sends a text message and subject line that are ISO-8859-1encoded in Italian. The recipient's email client will be able to display the email message using the specified ISO character set provided that it is capable of identifying ISO-8859 MIME parts (such as MS OutLook).
ISO8859.CBL must be edited with your email parameters before compiling.
The FORWARD example program forwards an (undecoded) email to a new recipient.
FORWARD.CBL must be edited with your email parameters before compiling.
The GmailMVP (Gmail Mailer Via Proxy) example console mode program emails a specified email message connecting to a GMAIL account via the (free) STUNNEL proxy server, which is started and terminated without user intervention. See gmail.txt in the DOCS directory or http://www.marshallsoft.com/gmail.htm for more information on STUNNEL.
There are four POP3 email example programs. These examples read email.
The GETRAW example program downloads a specified email message without decoding it. This program is used to see what the email looks like on the server.
The GETRAW.CBL program must be edited with your email parameters before compiling.
The STATUS example program reads the number of email messages waiting on your POP3 email server, and displays the "DATE:", "FROM:", and "SUBJECT:" header fields from each email.
The STATUS.CBL program must be edited with your email parameters before compiling.
The READER example program can read email, including multiple MIME attachments, from your POP3 email server, deleting each email after being read.
The READER.CBL program must be edited with your email parameters before compiling.
The READER2 example program operates like READER, except that it runs in direct mode rather than indirect mode like READER.CBL. The READER2.CBL program must be edited with your email parameters before compiling.
The READER2.CBL program must be edited with your email parameters before compiling.
The POP3RD example program uses the seePop3Source function to specify an (undecoded) email message file to be decoded.
The READER2.CBL program must be edited with your email parameters before compiling.
There are two IMAP-only example programs. These examples access the IMAP server.
The ImapFlag example program tests the manipulation of flags on the IMAP server. It reads, sets, and deletes certain flags for the specified email message on the IMAP server.
IMAP flags are:
\Seen Message has been read
\Answered Message has been answered
\Flagged Message is "flagged" for urgent/special attention
\Deleted Message is "deleted" for removal by later EXPUNGE
\Draft Message has not completed composition (marked as a draft).
\Recent Message has arrived since the previous time this mailbox was
selected. ["\Recent" may be fetched but not stored]
The ImapFlag.CBL program must be edited with your email parameters before compiling.
The ImapSrch example program tests IMAP search capability.
See ImapSearch.txt or http://www.marshallsoft.com/ImapSearch.htm for a complete list of all IMAP search strings.
Example search strings as passed to seeImapSearch():
SEEN
SEEN NOT ANSWERED
FLAGGED SINCE 1-Feb-2008 NOT FROM "Smith"
LARGER 10000 NOT SEEN
The ImapSrch.CBL program must be edited with your email parameters before compiling.
The SMTP/POP3/IMAP Email Engine DLL (SEE32.DLL) is written in ANSI C. All language versions of SEE (C/C++, Delphi, COBOL, PowerBASIC, FoxPro, dBase, Xbase++, COBOL, and Fortran) use the same identical DLL.
Version 1.0: June 8, 1998.
Version 2.0: [COBOL version not released]
Version 2.1: [COBOL version not released]
Version 3.0: [COBOL version not released]
Version 3.1: September 1, 1999.
Version 3.2: February 28, 2000.
Version 3.3: December 11, 2000
Version 3.4: August 14, 2001
Version 3.5: April 25, 2002
Version 3.6: May 5, 2003
Version 3.7: February 18, 2005.
Version 4.0: August 23, 2006.
Version 5.0: June 6, 2008 (Win32 Version only)
Version 5.1: June 17, 2009
Version 5.2: May 4, 2010 (Win32) version