Microsoft KB Archive/106033

{|
 * width="100%"|

-

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).

All the necessary files are located on the Workgroup Extensions disk that ships with FoxPro for Windows, Professional edition.

Below is an example of how to send a mail message in FoxPro for Windows.

MORE INFORMATION
The FoxPro Extensions come with FOXMAPI.FLL, MAPILIB.PRG, and MAPIERR.PRG. FOXMAPI.FLL is a 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 extra 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 FOXMAPI.FLL, MAPILIB.PRG, and MAPIERR.PRG. MAPILIB.PRG and MAPIERR.PRG should be in the same directory as the program below.

The following program sends a mail message to the e-mail name stored in m.toname; the subject line is stored in m.subject, and the text of the message is stored in m.notetext.

  ** START OF PROGRAM SET LIBRARY TO  *:          Calls: MAPILIB          (function in MAPILIB.PRG) *:              : MPLOGOFF         (function in FOXMAPI.FLL) *:  *:           Uses: MAPIMESG.DBF

** SET THE LIBRARY TO FOXMAPI.FLL SET LIBRARY TO C:\wgtplate\appendix\foxpro\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')

** Get Info To Send ** m.toname- 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. m.tonames="johndoe" m.subject="MAIL TEST-A SAMPLE SUBJECT LINE" m.notetext="THIS IS A TEST OF SENDING MAIL WITH FOXPRO."

** 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)

** Log off and cleanup ** 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 application programming interface

Keywords         : kbcode FxtoolLck Version          : 2.50 2.50a 2.50b Platform         : WINDOWS Issue type       :
 * }