>Hi Rich,
>
>Unrelated observation, but this is the first that I noticed in this code:
>
>Why do you create oshell = CREATEOBJECT("wscript.shell") in the SCAN loop? Seems to me you need to do it once outside and then simply run the commands.
>
I don't. It is actually created in the program which calls this function. I put it near the RUN() statement to show what was running.
>I'll look closer to the code.
>
>Also this
>FOR I = 1 TO lnRecips
>> oWWIP.cRecipient = ALLTRIM(aRecips[i])
>> oWWIP.SendMail()
>> ENDFOR
>
>may send multiple e-mails.
>
That is the intention. If the users enter multiple addresses with a semi-colon as delimiter the program does not send properly. I probably should have replaced the semi-colon with a comma, but sending a separate email to each recipient was the first thing I thought of and it worked so I never looked at a better way of doing it.
>In addition, do you have timer running? Do you disable the timer before running this code?
>
Yes I do and No I don't. We actually want the timer to fire again even if this code is still running. I can tell you that the second email is definitely not coming from a second timer.
Thanks for responding..........Rich
>>I have the following function (parts have been snipped for convenience)
>>DEFINE CLASS RunTasks as Custom
>> FUNCTION Run_scheduled_tasks()
>> oWWIP = CREATEOBJECT("wwIPStuff")
>> .
>> .
>> lcTime = TIME()
>> oMySQLData.Get_Scheduled_Tasks('zSchld_tasks')
>> SELECT what I need INTO CURSOR 'zTasks_toRun'
>> SELECT zTasks_toRun
>> SCAN
>> IF NOT EMPTY(ALLTRIM(zTasks_toRun.cParameters)) THEN
>> lcCommand = ALLTRIM(zTasks_toRun.cRunCmd) + ' ' + ALLTRIM(zTasks_toRun.cParameters)
>> ELSE
>> lcCommand = ALLTRIM(zTasks_toRun.cRunCmd)
>> ENDIF
>> oshell = CREATEOBJECT("wscript.shell")
>> oshell.run(lcCommand,1,.t.)
>> oMySQLData.Update_Task_LastRun(zTasks_toRun.CID)
>> oWWIP.cSubject = zTasks_toRun.ScheduleName + ' completed.'
>> oWWIP.cAttachment = TRIM(zTasks_toRun.cAttachments)
>> ** semi-colons not allowed. In case users try them
>> ** Separate Notify email list items with either comma or semi-colon
>> lnRecips = ALINES(aRecips,zTasks_toRun.cNotify,",",";")
>> FOR I = 1 TO lnRecips
>> oWWIP.cRecipient = ALLTRIM(aRecips[i])
>> oWWIP.SendMail()
>> ENDFOR
>> ENDSCAN
>> ENDFUNC
>>ENDDEFINE
>>
>>I've created a program which has several messageboxes.
>>
>>When I step through this code in the VFP Debugger the
oshell.run() line takes effect, the second program runs and I respond to all the messageboxes, and then the email gets sent.
>>
>>When the program runs unattended via an exe, the
oshell.run() line executes, an email is immediately sent, I respond to the messageboxes, and a second email is sent.
>>
>>I'm perplexed, confused, etc.
>>
>>Can anybody point me to what I might have set up incorrectly that would result in this behavior?
>>
>>Thanks to all..........Rich