How to Send Multiple Mail Messages with FoxPro Extensions
ID: Q113003
|
The information in this article applies to:
-
Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b
SUMMARY
The FoxPro Extensions that come with the Workgroup Templates enable FoxPro
developers to tap into the mail messaging API (MAPI) and the Microsoft
Schedule+ API (SPLUS). Below is an example of how to send multiple mail
messages in FoxPro for Windows when the addressee information, subject
line, and message come from a database.
MORE INFORMATION
The FoxPro Extensions come with FOXMAPI.FLL, MAPILIB.PRG, and MAPIERR.PRG.
FOXMAPI.FLL is a dynamic-link library (DLL) that is the interface between
FoxPro and MAPI.DLL and SPLUS.DLL. MAPILIB.PRG is a file containing
procedures that make calls to functions in FOXMAPI.FLL (instead of calling
the functions in FOXMAPI.FLL directly, parameters can be passed to
MAPILIB.PRG, which provides additional error checking). MAPIERR.PRG is
called by MAPILIB.PRG if an error condition occurs while a procedure in
MAPILIB.PRG is being executed.
For more information about the functions used in this example, examine
MAPILIB.PRG to find the function that is called in MAPILIB.PRG and then see
what function MAPILIB.PRG calls in FOXMAPI.FLL. The Help file located in
C:\WGTPLATE\APPENDIX\FOXPRO\FOXMAPI.HLP explains what the functions in
FOXMAPI.FLL do.
For the following example to work, you must have the FOXMAPI.FLL,
MAPILIB.PRG, and MAPIERR.PRG files. MAPILIB.PRG and MAPIERR.PRG should be
in the same directory as the program below.
The program below sends a mail message for each record in the MAILDAT.DBF
file. The structure of the MAILDAT.DBF file is as follows:
Field Field name Type Width
--------------------------------------------
1 TONAMES Character 20
2 SUBJECT Character 60
3 NOTETEXT Character 254
The TONAMES field contains the addressee's e-mail name, the SUBJECT field
contains the text for the subject line, and the NOTETEXT field contains the
message to be sent.
Program Example
CLOSE ALL
USE maildat
SET LIBRARY TO foxmapi.fll
** MAPILIB.PRG and MAPIERR.PRG must be in the same directory
** as this program for things to work properly.
** MAPILIB.PRG calls FOXMAPI.FLL.
** Log on to mail.
msession=MAPILIB('LOGON')
* Continue until the end of the MAILDAT file is reached.
DO WHILE NOT EOF()
** Get Info To Send by doing a SCATTER MEMVAR.
** m.tonames- The e-mail name of the person the message is
** addressed to.
** m.subject- The subject line of the e-mail message.
** m.notetext- The text of the e-mail message.
SCATTER MEMVAR
** Create mapiRecip cursor.
** Resolve name.
=MAPILIB('resolve',msession,m.tonames)
** Send message.
=MAPILIB('newcursor','mapiFile')
=MAPILIB('newcursor','mapiMesg')
INSERT INTO mapimesg VALUES(0,m.subject,m.notetext,'IPM.',;
MAPILIB('getdate'),'',0,RECCOUNT('mapiRecip'),0)
retval=mapilib("sendmail",msession,"mapiMesg","mapiRecip",;
"mapiFile",0)
* Close cursors.
SELECT mapiFile
USE
SELECT mapiMesg
USE
SELECT mapiRecip
USE
SELECT maildat
* Go to the next record and send the next mail message.
SKIP 1
ENDDO
** Log off and clean up.
** Logging off by directly calling the mplogoff function in
** FOXMAPI.FLL.
=mplogoff(msession,0,0,0)
CLEAR ALL
CLOSE ALL
RELEASE ALL
SET LIBRARY TO
** END OF PROGRAM
Additional query words:
FoxWin 2.50 email electronic mail
Keywords : kbcode FxtoolLck
Version : 2.50 2.50a 2.50b
Platform : WINDOWS
Issue type :