>DEFINE CLASS ApplicationEvents AS custom > > PROCEDURE ItemSend(Item,Cancel) > * Add user code here > ENDPROC > > PROCEDURE NewMail > * Add user code here > local lnhand > lnhand = fcreate("c:\temp\outlook.txt") > if lnhand > 0 then > =fputs(lnhand,"File just created") > =fclose(lnhand) > endif > ENDPROC > > PROCEDURE OptionsPagesAdd(Pages) > * Add user code here > ENDPROC > > PROCEDURE Quit > * Add user code here > ENDPROC > > PROCEDURE Reminder(Item) > * Add user code here > ENDPROC > > PROCEDURE Startup > * Add user code here > ENDPROC >ENDDEFINE>I add the code to the NewMail method. When bound togther, eveytime you receive a new message in Outlook that code will execute.
>ovfpcom = createobject("vfpcom.comutil") >ooutlook = getobject(,"outlook.application") && gets reference to currently running instance of Outlook >oappevents = newobject("applicationevents") && create instance of exported class >ovfpcom.BindEvents(ooutlook,oappevents) && bind the two objects together>Whenever the user sends something, you get an object reference to it in the Item parameter. You can query it, change it, etc. When a user receives new mail, the NewMail method will fire. You can open the Inbox, get the new mail, extract information from it and populate VFP tables if you want.