O
Ottar
I've made a program sorting incomming mail in public folder.
The function runs every minute by using the form.timer event.
In Access XP it runs for weeks, no problem. Access 2003 runs the same
code for 6 hours and stops.
I've found the problem to be the Set MySession =
CreateObject("MAPI.Session")
I've made a test program:
Function MAPI_Test()
Dim i As Integer
Dim OK As Boolean
Dim MySession As MAPI.Session
i = 0
OK = True
While (i < 2000) And OK
OK = MAPI_Logon(MySession)
If OK Then OK = MAPI_Logoff(MySession)
Debug.Print i
i = i + 1
DoEvents
Wend
End Function
In Access XP this runs until i = 2000
In Access 2003 the function stops after 380 iterations. The error is
E_MAPI_INVALID_OBJECT. I have to close down Access then i get "a new
qutoa" of 380.
I've downloaded latest fix'es from Microsoft.
Any ideas welcome!
Below is the Logon / Logoff functions used above.
Function MAPI_Logon(Session As MAPI.Session) As Boolean
Set Session = CreateObject("MAPI.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administrator"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function
Function MAPI_Logoff(Session As MAPI.Session) As Boolean
On Error Resume Next
Session.Logoff
If Err.Number <> 0 Then MAPI_Logoff = False Else MAPI_Logoff = True
End Function
The function runs every minute by using the form.timer event.
In Access XP it runs for weeks, no problem. Access 2003 runs the same
code for 6 hours and stops.
I've found the problem to be the Set MySession =
CreateObject("MAPI.Session")
I've made a test program:
Function MAPI_Test()
Dim i As Integer
Dim OK As Boolean
Dim MySession As MAPI.Session
i = 0
OK = True
While (i < 2000) And OK
OK = MAPI_Logon(MySession)
If OK Then OK = MAPI_Logoff(MySession)
Debug.Print i
i = i + 1
DoEvents
Wend
End Function
In Access XP this runs until i = 2000
In Access 2003 the function stops after 380 iterations. The error is
E_MAPI_INVALID_OBJECT. I have to close down Access then i get "a new
qutoa" of 380.
I've downloaded latest fix'es from Microsoft.
Any ideas welcome!
Below is the Logon / Logoff functions used above.
Function MAPI_Logon(Session As MAPI.Session) As Boolean
Set Session = CreateObject("MAPI.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administrator"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function
Function MAPI_Logoff(Session As MAPI.Session) As Boolean
On Error Resume Next
Session.Logoff
If Err.Number <> 0 Then MAPI_Logoff = False Else MAPI_Logoff = True
End Function