How To Send Mail Using MPSendMail() of FOXMAPI.FLLLast reviewed: February 20, 1998Article ID: Q152279 |
3.00 3.00b
WINDOWS
kbinterop kbhowto
The information in this article applies to:
SUMMARYFoxmapi.fll is a DLL interface to Mapi.dll and Splus.dll. This article describes how to use the MPSendMail function in FOXMAPI. Information on obtaining the FOXMAPI files for your version of FoxPro is as follows:
MORE INFORMATIONThe following program will create and send a simple mail message. See the FOXMAPI.HLP file, provided with FOXMAPI.FLL, for explanations of error codes that may be returned by each function:
#DEFINE success_success 0 #DEFINE mp_e_type_not_supported 20 ** Load FOXMAPI Library cLib = "" IF ! ("FOXMAPI" $ UPPER(SET("LIBRARY"))) IF FILE("FOXMAPI.FLL") cLib = FULLPATH("FOXMAPI.FLL") ELSE cLib = LOCFILE("FOXMAPI.FLL","FLL","Where is FoxMAPI?") IF EMPTY(cLib) WAIT WINDOW "FOXMAPI Not Found ... press any key to exit" RETURN ENDIF ENDIF SET LIBRARY TO &cLib ADDITIVE ENDIF * Logon to Mail nSession = 0 && Variable to Receive MAPI session nSuccess = MPLogon(0,"","",1,0,@nSession) IF nSuccess # success_success DO errhand WITH nSuccess, "Login" RETURN ENDIF * Create FoxPro cursors for Message, Recipients, * and File Attachments lSuccess = MPCursor("MapiMesg") IF ! lSuccess WAIT WINDOW "Could not create Message Cursor ... " + ; " press any key to exit" RETURN ENDIF lSuccess = MPCursor("MapiRecip") IF ! lSuccess WAIT WINDOW "Could not create Recipients Cursor ... " + ; " press any key to exit" RETURN ENDIF lSuccess = MPCursor("MapiFile") IF ! lSuccess WAIT WINDOW "Could not create File Attachments Cursor " + ; " ... press any key to exit" RETURN ENDIF * Load the Message cursor SELECT MapiMesg APPEND BLANK * The reserved field must be 0 (zero) REPLACE reserved WITH 0 * Change the text to your subject REPLACE subject WITH "My Subject" * Change the text to text of your message REPLACE notetext WITH "This is the text of my message" * RecipCount indicates the number of recipients. This should correspond * to the number of records in the MapiRecip cursor. For a simple * example, we will only use one (1). REPLACE recipcount WITH 1 * FileCount indicates the number of file attachments. This should * correspond to the number of records in the MapiFile cursor. For a * simple example, we will not have any file attachments. REPLACE filecount WITH 0 * Messagtype, if left blank, defaults to "IPM". If you receive * Unsupported Type on the MPSendMail function, you will need * to determine what type of message is required by your mail * system (you can do this by checking the Messagtype field after * using the MPReadMail function). The two remarked lines below * are examples that worked on two different systems. * REPLACE messagtype WITH "IPM.Microsoft Mail.Note" * REPLACE messagtype WITH "IPM.Note" * Load the Recipients cursor SELECT MapiRecip * The lines below would need to be repeated for each * recipient of your message. **************** APPEND BLANK * The reserved field must be zero (0) REPLACE reserved WITH 0 * Change the text below to the name (email or friendly) * of the Recipient REPLACE name WITH "My Name" * Let Mail fill in the rest by resolving the name nSuccess = MPResolve(nSession, 0, mapirecip.name, ; 0, 0, "MapiRecip") IF nSuccess # success_success DO errhand WITH nSuccess, "MPResolve" RETURN ENDIF *************** * Send the Message nSuccess = MPSendMail(nSession, 0, ; "MapiMesg", "MapiRecip", "MapiFile", 0, 0) DO CASE CASE nSuccess = mp_e_type_not_supported DO errhand WITH nSuccess, "MPSendMail", ; "Message Type Not Supported" RETURN CASE nSuccess # success_success DO errhand WITH nSuccess, "MPSendMail" RETURN ENDCASE * Logoff of Mail nSuccess = MPLogOff(nSession, 0, 0, 0) PROCEDURE errhand PARAMETER nErrnum, cLocation, cMessage message = "Error on " + cLocation + ": " IF EMPTY(cMessage) message = message + ALLTRIM(STR(nErrnum)) ELSE message = message + cMessage ENDIF message = message + " ... press any key to exit" WAIT WINDOW message RELEASE LIBRARY FOXMAPI RETURNNOTE: Under Microsoft FoxPro for Windows, version 2.x, Foxmapi.fll is designed to interface with Microsoft Mail. It may not work with Microsoft Exchange. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
|
Additional reference words: 3.00 3.00b VFoxWin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |