'Outlook VBA Script for Delaying Send and Receive
I'm currently working on a VBA script for Outlook, which needs to stop automatic Send/Receive and make it every 5 minutes. I don't have a problem with the delay – it's just that I don't know how to stop Send/Receive in the script.
Solution 1:[1]
The Outlook object model provides the Offline property which returns a boolean indicating true if Outlook is offline (not connected to an Exchange server), and false if online (connected to an Exchange server). But it is read-only.
You can use the following workaround:
Sub SetOffline()
Dim oNS As NameSpace
Set oNS = Application.Session
If oNS.ExchangeConnectionMode <> olCachedOffline And oNS.ExchangeConnectionMode <> olOffline Then
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim objExpl As Outlook.Explorer
Set olNS = Application.GetNamespace("MAPI")
Set objExpl = Application.ActiveExplorer
objExpl.CommandBars.ExecuteMso ("ToggleOnline")
End If
End Sub
The SyncObject.SyncStart event doesn't provide any parameter to stop the syncing process. The best what you could do is to set the offline state to prevent syncing.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eugene Astafiev |
