Link to home
Start Free TrialLog in
Avatar of NerishaB
NerishaBFlag for South Africa

asked on

Javascript to close Outlook, then wait a few seconds, and then reopen outlook

Hi

I have a very difficult user who never shuts down his outlook, and when he comes in, in the morning, finds out that his Outlook does not work properly.  The solution that I have come up with is to automatically shut down his Outlook for him.  I already have a script to do that (see attached code).  But now he complains that he has to manually open up outlook again, so I was wondering if anyone knew what I can add to allow my code to run, then wait 5 seconds, and then open up outlook again. Any help will be appreciated.
Dim oOL As Outlook.Application
Set oOL = GetObject(, "Outlook.Application")
If oOL Is Nothing Then
    'no need to do anything, Outlook is not running
Else
    'Outlook running
    For i = oOL.Inspectors.count To 1 Step -1
        oOL.Inspectors.Item(i).CurrentItem.Save
        oOL.Inspectors.Item(i).Close True
    Next
    oOL.Session.Logoff
    oOL.Quit
End If
Set oOL = Nothing

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of boing40001
boing40001
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NerishaB

ASKER

It's not in code form, but it is a solution to the problem.  Thanks