SMTP/POP3 Email Engine
Library for Visual FoxPro
Programmer's Manual
(SEE4FP)
Version 3.2
February 14, 2000
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 2000
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Voice : 256-881-4630
FAX : 256-880-0925
email : info@marshallsoft.com
web : www.marshallsoft.com
MarshallSoft is a member of the Association of Shareware Professionals
MARSHALLSOFT is a registered trademark of MarshallSoft Computing.
1 Introduction
1.1 Documentation Set2 Compiler Issues
1.2 Example Program
1.3 Installation
1.4 Uninstalling
1.5 Ordering
1.6 Updates
2.1 INCLUDE Files3 Example Programs
2.2 Compiling Programs
2.3 Dynamic Strings
2.4 Using Internal Memory
2.5 Compiling to Executable
2.6 Key Codes
3.1 Version4 Revision History
3.2 Hello
3.3 Mailer
3.4 Status
3.5 Status2
3.6 Reader
3.7 Auto
3.8 GetRaw
SEE4FP is the easiest way to write email applications in Visual FoxPro !
The SMTP/POP3 Email Engine (SEE) is a library of functions providing direct and simple control of the SMTP (Simple Mail Transport Protocol) and POP3 (Post Office 3) protocols.
A simple interface allows sending and receiving email, including multiple MIME base64 and quoted- printable encoded attachments. Knowledge of Winsock and TCP/IP is not needed.
With SEE4FP, you can write programs that easily:
Ten example programs are included, demonstrating SMTP and POP3 functions. All programs will compile using any version of Visual FoxPro.
A Dynamic Link Library (SEE32.DLL) is provided. SEE4FP can be used with Windows 95, 98, and NT. The SEE4FP DLL (SEE32.DLL) can also be used from any language (C/C++, Delphi, VB, etc.) capable of calling the Windows API.
When comparing SEE against our competition, note that:
The complete set of documentation consists of three manuals in three formats. This is
the first manual
(SEE4FP) in the set.
Each manual comes in three formats:
The following example segment demonstrates the use of some of the library functions:
#INCLUDE KEYCODE.FOX #INCLUDE SEE32CON.FOX DECLARE INTEGER seeAttach in SEE32.DLL INTEGER NbrChans, INTEGER KeyCode DECLARE INTEGER seeClose in SEE32.DLL INTEGER Chan DECLARE INTEGER seeErrorText in SEE32.DLL INTEGER Chan, INTEGER Code, STRING @Buffer,INTEGER BufLen DECLARE INTEGER seeIntegerParam in SEE32.DLL INTEGER Chan, INTEGER Param, INTEGER Value DECLARE INTEGER seeRelease in SEE32.DLL DECLARE INTEGER seeStringParam in SEE32.DLL INTEGER Chan, INTEGER Param, STRING @Value *** PROGRAMMER: Edit these strings [use host name or IP address for server] *** SmtpServer = "10.0.0.1" SmtpFrom = "<mike@10.0.0.1>" SmtpReply = "" SmtpTo = "<mike@10.0.0.1>" DiagFile = "HELLO.LOG" *** END PROGRAMMER *** ? "HELLO 02/10/2000" Code = seeAttach(1, SEE_KEY_CODE) if Code < 0 ? "Cannot attach SEE" return endif Code = seeStringParam(0, SEE_LOG_FILE, @DiagFile) *** set maximum connect wait to 10 seconds Code = seeIntegerParam(0, SEE_CONNECT_WAIT, 10000) *** connect to POP3 server ? "Connecting to " + SmtpServer Code = seeSmtpConnect(0, @SmtpServer, @SmtpFrom, @SmtpReply) if Code < 0 Temp = SPACE(128) Code = seeErrorText(0,Code,@Temp,128) ? Left(Temp,Code) else *** send email message ? "Sending email to " + SmtpTo Code = seeSendEmail(0,SmtpTo,"","","Hello from FoxPro","Hello from FoxPro","") if Code < 0 Temp = SPACE(128) Code = seeErrorText(0,Code,@Temp,128) ? Left(Temp,Code) else ? "Email has been sent." endif endif ? "Done." Code = seeClose(0) Code = seeRelease() return
In the example program above, seeAttach is called to initialize SEE and then seeSmtpConnect is called to connect to the SMTP mail host. seeSendEmail is then called, passing the addressee lists. The primary addressee is provided in the "To List". Lastly, the filename of any ASCII or binary attachment is specified. All fields in seeSendEmail are optional except the first.
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.
INSTALL
The INSTALL.BAT program copies SEE32.DLL to either C:\WINDOWS (for Windows 95/98) or
C:\WINNT (for Windows NT 4.0).
Note that the Windows registry is not modified by the install process.
Uninstalling SEE4FP is very easy. SEE does not modify the registry.
First, run UINSTALL.BAT, which will delete SEE16.DLL and SEE32.DLL from your Windows directory, typically C:\WINDOWS for Windows 95/98 or C:\WINNT for Windows NT.
Second, delete the SEE project directory created when installing SEE4FP.
See the section "Ordering" in the SEE User’s Manual (SEE_USR) for details on ordering.
When you register SEE4FP you will receive a set of registered DLLs plus a license file
(SEExxxx.LIC)
that can be used to update your registered DLL’s for a period of one year from purchase.
Updates can be
downloaded from
http://www.marshallsoft.com/oem.htm
After one year, licenses can be updated for $30 for email delivery.
All example programs include two files; KEYCODE.FOX and SEE32CON.FOX. The file SEE32CON.FOX contains all the necessary constants for SEE4FP, while the file KEYCODE.FOX contains your key code, as discussed in section 2.4 below.
Since function declarations cannot be in an include file (at least through VFP version 5.0), they are listed in each program following the two include files. The complete list of function declarations is also in file SEE32FUN.FOX
The example programs are compiled from the Visual FoxPro development environment.
Before running
the example programs:
For more information on host names and email address formats, refer to the SEE User's Manual (SEE_USR). See section 3.0 "Example Programs" for more details on each of the example programs.
The Visual FoxPro language use a technique known as "garbage collection" to manage string space at runtime, and may be called internally at any time by the FoxPro runtime, asynchronous to what you may be doing in your code.
When passing a string buffer to a DLL function into which text will be copied, it is strongly recommended that the local string be allocated immediately before use. For example:
Code = seeSmtpConnect(0,@SmtpServer,@SmtpFrom,@SmtpFrom) if Code < 0 * allocate buffer just before call Temp = SPACE(128) * put text in Temp Code = seeErrorText(1,Code,@Temp,128) ? Left(Temp,Code) endif
This technique is not necessary for passing a string to a DLL function, only when passing a buffer to a DLL into which data is to be placed by the DLL function.
This section applies ONLY to using DIRECT mode as discussed in the section "Theory Of Operation" in the SEE User's Manual (SEE_USR).
The Visual FoxPro dynamic string management functions (as discussed in section 2.3 above) have another
side effect when running in DIRECT mode (calling seeDriver): if Visual FoxPro moves memory
at
runtime, then memory references by FoxPro will use the new (moved) memory location,
although SEE
itself will still be using the original memory location previously passed to it. To get
around this problem
with Visual FoxPro (and other languages that do dynamic string management) , you can
instruct
seeGetEmailLines to use it's own memory:
Code = seeGetEmailLines(Chan, MessageNumber, 0, 0, max_buf_size)
If the 4th argument is 0, SEE will use it's own memory. After seeDriver has been called to completion, the internal buffer can be copied by calling
Buffer = SPACE(max_buf_size)
Code = seeDebug(0, SEE_COPY_BUFFER, @Buffer, max_buf_size)
seeGetEmailLines is the only function which requires this technique, since there is no reason to use direct mode in other functions (such as seeErrorText) that use return buffers. See the program STATUS2.PRG for an example of using seeGetEmailLines in direct mode.
FoxPro programs end in ".PRG". They can be compiled to an executable using the FoxPro BUILD command.
For example, to create SEEVER.EXE from SEEVER.PRG in the C:\TEMP directory, type the following in the FoxPro command window:
BUILD PROJECT C:\TEMP\SEEVER FROM C:\TEMP\SEEVER
BUILD EXE C:\TEMP\SEEVER FROM C:\TEMP\SEEVER
FoxPro executables require VFP500.DLL and VFP5ENU.DLL (ENglish User), and may have to be copied from the VFP CDROM. If you are using an earlier or later version of FoxPro than version 5.0, substitute the appropriate DLL's for the above.
The FoxPro output display window will disappear as soon as your executable completes. In order to allow the user to control when the display window disappears, add the following code to your application, just before the final return.
? " Type any key to exit..." X = InKey(0)
SEE32.DLL has a keycode encoded within it. Your keycode is a 9 or 10 digit decimal number (unless it is zero), and will be found in the file KEYCODE.FOX. The keycode for the shareware version is 0. You will receive a new key code when registering. Your keycode is not your customer ID (which is a 5 digit number).
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 shareware version of the SEE DLL's from the Windows search path.
Each example program, with the exception of SEEVER.PRG, must be editied with your TP/IP email parameters before compiling. Refer to the SEE User's Manual (SEE_USR) for details.
This simple program displays the SEE version number, build number, and registration string taken from SEE32.DLL. The SEEVER program does not connect to your LAN (or the Internet).
This is the first program that you should compile and run.
The HELLO program emails a short message. HELLO.PRG must be edited with your email parameters before compiling.
Compare HELLO with the MAILER example program.
The MAILER example program emails a message, including an optional MIME attachment. MAILER.PRG must be edited with your email parameters before compiling.
STATUS reads the number of email messages waiting on your POP3 server, and displays the "DATE:", "FROM:", and "SUBJECT:" header fields from each email. STATUS.PRG must be edited with your email parameters before compiling.
The STATUS2 example program operates the same as the STATUS program, except that it uses the "indirect" method (refer to SEE User's Manual SEE_USR). The function seeDriver is called automatically. STATUS2.PRG must be edited with your email parameters before compiling.
Compare STATUS2.PRG with STATUS.PRG.
READER can read email, including multiple MIME attachments, from your POP3 server, deleting each email after being read. READER.PRG must be edited with your email parameters before compiling.
AUTO ("auto-responder") uses two channels concurrently to automatically respond to all new email. AUTO.PRG must be edited with your email parameters before compiling.
GETRAW is an example program that downloads a specified email message without decoding it (in "raw" format). This is used to see what the email looks like on the server. GETRAW.PRG must be edited with your email parameters before compiling.
The SMTP/POP3 Email Engine DLLs (SEE16.DLL and SEE32.DLL) are written in ANSI C. All language versions of SEE (C/C++, Visual Basic, PowerBASIC, Delphi, Visual FoxPro, Visual dBase, Xbase++, COBOL, and Fortran) use the same identical DLLs.
Version 3.0: June 10, 1999.
Version 3.1: August 3, 1999.
Version 3.2: February 14, 2000.