'VBScript WaitForOutlook.VBS Set WshShell = Wscript.CreateObject("WScript.Shell") ' this waits 20 seconds from launch to action. You can experiment with ' shorter or longer durations as necessary Wscript.Sleep 20000 WshShell.AppActivate "Microsoft Outlook" ' wait 1/10th second after requesting activation of the Outlook Window Wscript.Sleep 100 WshShell.SendKeys "Y"Step 2 Create your MAPI email code in VFP and add the following
* * Immediately before invoking the MAPI Send or Outlook Send * Launch the script created above. You must not have an explicit * instance of Outlook running visible on the taskbar, or it may * send the keystroke to the wrong instance * * I am not taking responsibility for anyone else's failure to implement this * using the code I show here. I don't care if you don't like WSH, it's a * necessary part of this solution. You can code it in JScript instead of * VBScript, or you can write a little C# or VB.Net to accomplish the same * delay and keystroke direction task; it's up to you. I'm not going to * debug your code for you; I'm not going to try to support OE with it. * SET CLASSLIB TO wwIPStuff ADDITIVE oIP = CREATEOBJ('wwIPStuff') WITH oIP .cSenderName = 'Ed Rauh' .cSenderEmail = 'edr@edrauh.com' .cRecipient = 'someone@anothersite.com' .cCCList = 'bozo@clown.net,edrauh@eviltwin.org' .cSubject = 'My VBScript message' .cMessage = 'Nyah, nyah, nyah I didn't have to click "Yes"!' .cAttachment = 'waitforoutlook.vbs' * * Here's the magic! * <b>RUN /N7 cscript waitforoutlook.vbs</b> .SendMAPIMail() ENDWITH oIP = NULLIf you're using the Outlook object model, invoke the script instance immediately before invoking the Send method of the MailItem subobject. I've tested both - they work, and work well. There are speed advantages to using the wwIPStuff SendMAPIMail method (probably, it can be adapted to Nigel Coates' MAPIMail class, and likely his OutlookMail class as well).