ddantes
asked on
VBS to open outlook.exe and perform send/receive
Running Outlook 2007 on a Windows 7 platform, I would like a VBS script which will open Ouitlook, perform a send/receive, and close Outlook. I plan to use this VBS in association with a POP Email checker, so that messages will be automatically downloaded if a message with specific criteria is found on the server.
The following code will open Outlook, but I need help with coding the send/receive and then closing Outlook...
Dim WshShell
Set WshShell=WScript.CreateObj ect("WScri pt.Shell")
WshShell.run "Outlook"
If Err <> 0 then
Err.Clear
Set ObjOL= CreateObject("Outlook.Appl ication")
End If
The following code will open Outlook, but I need help with coding the send/receive and then closing Outlook...
Dim WshShell
Set WshShell=WScript.CreateObj
WshShell.run "Outlook"
If Err <> 0 then
Err.Clear
Set ObjOL= CreateObject("Outlook.Appl
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
However, I did find code which accomplishes these tasks:
set WshShell = WScript.CreateObject("WScr
WshShell.Run "outlook"
WScript.Sleep 20000
WshShell.AppActivate "Outlook"
WScript.Sleep 1000
WshShell.SendKeys "{F9}"
WScript.Sleep 28000
Dim ObjOL 'As Outlook.Application
Set ObjOL = CreateObject("Outlook.Appl
If ObjOL Is Nothing Then
'no need to do anything, Outlook is not running
Else
'Outlook running
ObjOL.Session.Logoff
ObjOL.Quit
End If
Set ObjOL = Nothing