I am using the following code to refresh my Outlook Inbox before searching it for responses to certain emails:
I'm having 2 issues with the code which both seem to me to be caused by a delay in the communication between Outlook and Access.
The first is that the code often throws an error 462 (remote server unavailable), which I understand from searching for a solution is a common problem when running other Office applications via vba. I've resolved that issue as best I could by trapping and clearing the error.
The second issue bewilders me. There seems to be about a 15 minute delay between when an email is received and when shows up in the Outlook inbox. I have this Outlook email account set up so that emails are forwarded to another non-Outlook account. Even after having received an email in the forwarded account inbox, the above code does not seem to receive it in the Outlook inbox until about 15 minutes later. Does this make sense? Is there something I can do to eliminate the delay?
Any help would be appreciated!
Sup
Code:
Public Sub RefreshInbox()
Dim nsp As Outlook.NameSpace
Dim sycs As Outlook.SyncObjects
Dim syc As Outlook.SyncObject
Dim i As Integer
On Error GoTo RefreshInbox_Error
Set nsp = Outlook.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For i = 1 To sycs.Count
Set syc = sycs.Item(i)
syc.start
Next
syc.Stop
Set nsp = Nothing
Set sycs = Nothing
Set syc = Nothing
On Error GoTo 0
Exit Sub
RefreshInbox_Error:
If err.Number = 462 Then
err.Clear
Else
MsgBox "Error " & err.Number & " (" & err.Description & ") in procedure RefreshInbox of Module nsReadInbox"
End If
End Sub
I'm having 2 issues with the code which both seem to me to be caused by a delay in the communication between Outlook and Access.
The first is that the code often throws an error 462 (remote server unavailable), which I understand from searching for a solution is a common problem when running other Office applications via vba. I've resolved that issue as best I could by trapping and clearing the error.
The second issue bewilders me. There seems to be about a 15 minute delay between when an email is received and when shows up in the Outlook inbox. I have this Outlook email account set up so that emails are forwarded to another non-Outlook account. Even after having received an email in the forwarded account inbox, the above code does not seem to receive it in the Outlook inbox until about 15 minutes later. Does this make sense? Is there something I can do to eliminate the delay?
Any help would be appreciated!
Sup