When 'driving' MS Outlook via VFP automation, I have noticed something that I'd like to confirm (or not).
By creating an Outlook object and using automation, my VFP application can successfully pass emails to Outlook. And the application issues the SEND command after handing Outlook each separate email.
But unless Outlook is actually Open (Launched) on the workstation desktop (before or after the VFP application runs), the SEND does not appear to really be performed. It seems as though the email document is held within Outlook's Draft folder with a pending SEND until the workstation's Outlook is actually launched.
In order to resolve the Has-to-be-Launched problem I have added VFP code to actually launch Outlook at the start of the SendEmail routine, not just create an object within the routine.
The above Launch utility works well, but the problem encountered is that I often end up with multiple copies of Outlook running (Outlook might already be open from before, or by a user's manual action, etc.) which consumes workstation memory and brings everything down to a slow crawl.
First question - Is this how other's have observed Outlook to work with VFP automation?
Next question - Suggestions or advice as to how to get around the problem(s)?
Thanks,
JRB-Bldr
By creating an Outlook object and using automation, my VFP application can successfully pass emails to Outlook. And the application issues the SEND command after handing Outlook each separate email.
But unless Outlook is actually Open (Launched) on the workstation desktop (before or after the VFP application runs), the SEND does not appear to really be performed. It seems as though the email document is held within Outlook's Draft folder with a pending SEND until the workstation's Outlook is actually launched.
In order to resolve the Has-to-be-Launched problem I have added VFP code to actually launch Outlook at the start of the SendEmail routine, not just create an object within the routine.
Code:
tcEXEFile = ADDBS(mcOutlookPath) + "OUTLOOK.EXE"
tcParameters = ""
tcCmd = "Open"
tcCmd = PROPER(m.tcCmd)
* API Call to communicate with an application based on the registered file-type.
* For example:
* On my computer txt is notepad; DOC is word
DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
lnFileStatus = ShellExecute(0,"&tcCmd",tcEXEFile,tcParameters,"",1)
mnAppHndl = 0
mlRet = .T.
DO CASE
CASE m.lnFileStatus > 32
* successful open
mnAppHndl = m.lnFileStatus
CASE m.lnFileStatus = 2
MESSAGEBOX("Bad Association (for example, invalid URL)",;
"AppLauch Method -- AppLauch Method")
CASE m.lnFileStatus = 29
MESSAGEBOX("Failure to load application","AppLauch Method -- AppLauch Method")
CASE m.lnFileStatus = 30
MESSAGEBOX("Application is busy","AppLauch Method -- AppLauch Method")
CASE m.lnFileStatus = 31
MESSAGEBOX("No application association with specified "+;
"command: " + m.tcCmd,"AppLauch Method -- AppLauch Method")
OTHERWISE
MESSAGEBOX("Unknown Error","AppLauch Method -- AppLauch Method")
mlRet = .F.
ENDCASE
The above Launch utility works well, but the problem encountered is that I often end up with multiple copies of Outlook running (Outlook might already be open from before, or by a user's manual action, etc.) which consumes workstation memory and brings everything down to a slow crawl.
First question - Is this how other's have observed Outlook to work with VFP automation?
Next question - Suggestions or advice as to how to get around the problem(s)?
Thanks,
JRB-Bldr