How to Send an OLE Object in Mail from Within FoxProLast reviewed: April 29, 1996Article ID: Q107831 |
The information in this article applies to:
SUMMARYThe 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 a simple example of how to send an embedded OLE object in a mail message from FoxPro for Windows.
MORE INFORMATIONThe FoxPro Extensions come with FOXMAPI.FLL, MAPILIB.PRG, and MAPIERR.PRG.
The example below will send the CARS.BMP bitmap file specified by the variable M.PATHNAME to the person that is specified in the M.TONAMES variable. For the following example to work, you must have FOXMAPI.FLL, MAPILIB.PRG, and MAPIERR.PRG. MAPILIB.PRG and MAPIERR.PRG should be located in the same directory as the program below.
** Unload any library that is in memory. SET LIBRARY TO ** SET THE LIBRARY TO FOXMAPI.FLL SET LIBRARY TO foxmapi.fll ** NOTE: MAPILIB.PRG and MAPIERR.PRG need to be in the same ** directory as this program for things to work properly. ** MAPILIB.PRG calls FOXMAPI.FLL ** Log on to mail and get session handle msession=MAPILIB('LOGON') ** Get info to send ** 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. m.tonames="JOHN DOE" m.subject="ATTACH MAIL TEST" m.notetext=SPACE(200) m.position=1 && This position is where to insert object m.pathname="c:\windows\cars.bmp" && Path and file of OLE object m.filename="" && Indicates to use pathname ** create mapiRecip cursor ** resolve name ** The MapiRecip cursor contains information about a message ** originator or recipient. =MAPILIB('resolve',msession,m.tonames) ** Create mapiFile and mapiMesg cursors. ** mapiFile contains information about a file attachment. ** mapiMesg contains information about a message. ** See the help file for more information. =MAPILIB('newcursor','mapiFile') =MAPILIB('newcursor','mapiMesg') ** Insert the needed information. INSERT INTO mapiFile VALUES(0,0,1,m.pathname,m.filename,; "") INSERT INTO mapiMesg VALUES(0,m.subject,m.notetext,'IPM.',; MAPILIB('getdate'),'',0,RECCOUNT('mapiRecip'),1) 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 reference words: FoxWin 2.50 2.50a 2.50b mapi ext
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |