FYI: I also had some problems with the MAPI class - re "Appropriate License for this class not found"
Here are some additional notes excert from my code that may be of help to others:
------------------------
in the init:
------------------------
with this
* ---INSTANTIATE MAPI OCX AND CHECK THAT IT IS AVAILABLE---
*
* NB: We trap any instantiation errors in the error() method
* ( .p_ole_instantiation_error gets set to .T.)
*
*
* NOTES:
*
* 1. This container is DELIBERATELY empty, and then the
* .Ole_mapi_session, and .Ole_mapi_messages objects
* are added to it here in the init via .newobject()
*
* It is done this way - because if the MAPI controls
* were instead dropped into the container at design time,
* and the MAPI32.OCX did not exist on the users PC, we
* would get an error - which cannot be trapped for in
* the .error() event.
* ( and we could not then run the this.m_register_ocx() )
*
* 2. When we add the .Ole_mapi_session, and .Ole_mapi_messages objects
* we do so from the objects that ALREADY exist in the SYMAPI.VCX
*
* i.e. rather than trying to add them (as some articles suggest) via:
* this.Ole_mapi_session = newobject("MSMAPI.MAPISession.1")
* this.Ole_mapi_messages = newobject("MSMAPI.MAPIMessages.1")
*
* (where .Ole_mapi_session and .Ole_mapi_messages are created as blank
* properties in the class at design time)
*
* Although the newobject("MSMAPI.MAPISession.1") etc works OK on a
* Developers PC - it may not work OK on Clients PCs at runtime, as
* you may get an error message:
* "Appropriate License for this class not found"
*
* This is a Bug in VFP 6
*
* For more details See MSDN article:
* 192693 - "BUG: License Error with ActiveX Control Added at Run-Time"
*
* ---Instantiate the MAPI OLE objects---
.NewObject("Ole_mapi_session","Ole_mapi_session","SYMAPI")
.NewObject("Ole_mapi_messages","Ole_mapi_messages","SYMAPI")
* ---Check for any instantiation errors---
if .p_ole_instantiation_error && gets set in .error
* There was a problem trying to instantiate the MAPI controls.
* ---Re-copy necessary files, and re register them---
.m_register_ocx()
* ---Try again to instantiate the MAPI OLE objects---
* NB: We trap any instantiation errors in the error() method
.p_ole_instantiation_error = .F. && reset the Error flag
*
.NewObject("Ole_mapi_session","Ole_mapi_session","SYMAPI")
.NewObject("Ole_mapi_messages","Ole_mapi_messages","SYMAPI")
* ---Check again for problems---
if .p_ole_instantiation_error && gets set in .error
* There was STILL a problem trying to instantiate the MAPI controls.
* i.e. the m_register_ocx() did not resolve the problem
* - Give up.
.enabled = .F.
endif
endif
endwith && this
------------------------
in the error event:
------------------------
* ---If we encounter an error - then show why, disable MAPI etc---
LPARAMETERS nError, cMethod, nLine
* ---PROCESS ACCORDING TO ERROR TYPE---
with this
do case
case nError = 1426 .and. "CLASS NOT REGISTERED" $ upper(message())
*
* 1426 = Ole Error : "Class not registered"
*
* Happens when trying to add the mapi objects in the init.
* and the Mapi control hasnt been registered on this PC
*
* NB do NOT Display an error message
*
* The class will try and be registered via
* .m_register_ocx() in the .init
*
.p_ole_instantiation_error = .T.
* NB do NOT set .enabled = .F. here - it gets done in the init
* (gets re-enabled later if registration is sucessful)
etc
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only