472,365 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,365 software developers and data experts.

Bug in Access 2003 ? Error after 380 CreateObject("MAPI.Session")

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
Nov 13 '05 #1
7 4089
Ottar

It looks like you Dim the session variable in Function MAPI_Test, actually
instantiate it in MAPI_Login, but never destroy it anywhere. I think you'd
do better to Dim, Instantiate, and Destroy the session variable in the
MAPI_Test function. In effect what you are doing is creating a massive
memory leak. Eventually there is not enough memory to instantiate another
session and your routine fails. Try changing the MAPI_Test function so it
handles the creation and destruction of the session object.

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
Set MySession = CreateObject("MAPI.Session")
OK = MAPI_Logon(MySession)
If OK Then OK = MAPI_Logoff(MySession)
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Remove the line
Set Session = CreateObject("MAPI.Session")
from MAPI_Logon and see how things go.

Ron W

"Ottar" <la*****@earthling.net> wrote in message
news:43**************************@posting.google.c om...
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

Nov 13 '05 #2
Even without logging in / out (see small function below) you get the same
error: 80040108

Function MAPI_Test2()
Dim i As Integer
Dim MySession As MAPI.Session
i = 0
While (i < 2000)
Set MySession = CreateObject("MAPI.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthling.net> wrote in message
news:43**************************@posting.google.c om...
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

Nov 13 '05 #3
CDB
1. Why are you trying to open 2,000 external instances of a Mapi session in
succession? It seems a pointless test - except to find out where the
stupidity point is. 380 sounds pretty good.

2. Place the session lines in a separate procedure so that VBA cleans up
after each termination.

3. Don't repost within a few minutes - exercise patience.

4, On which line does the error arise?

Clive
"Ottar L. Osen" <la*************@earthling.net> wrote in message
news:O9**************@TK2MSFTNGP11.phx.gbl...
Even without logging in / out (see small function below) you get the same
error: 80040108

Function MAPI_Test2()
Dim i As Integer
Dim MySession As MAPI.Session
i = 0
While (i < 2000)
Set MySession = CreateObject("MAPI.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthling.net> wrote in message
news:43**************************@posting.google.c om...
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


Nov 13 '05 #4
Hm, you probably did not read part 1 of my message, its quoted below, but
I'll be nice and copy it up here for you:
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

As you see loging On and Off are done in external functions, logon procedure
creates object. I've not included the whole program, I've included a program
that illustrates the problem. Finally I boiled the problem down to the small
program you find stupid.
My problem is that whatever I do after 380 object creations it fails. Not so
in XP, just in 2003.
If you have a solution to my problem I am glad to hear it.
Yours Ottar

"CDB" <al***@delete.wave.co.nz> wrote in message
news:cb**********@news.wave.co.nz...
1. Why are you trying to open 2,000 external instances of a Mapi session in succession? It seems a pointless test - except to find out where the
stupidity point is. 380 sounds pretty good.

2. Place the session lines in a separate procedure so that VBA cleans up
after each termination.

3. Don't repost within a few minutes - exercise patience.

4, On which line does the error arise?

Clive
"Ottar L. Osen" <la*************@earthling.net> wrote in message
news:O9**************@TK2MSFTNGP11.phx.gbl...
Even without logging in / out (see small function below) you get the

same error: 80040108

Function MAPI_Test2()
Dim i As Integer
Dim MySession As MAPI.Session
i = 0
While (i < 2000)
Set MySession = CreateObject("MAPI.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthling.net> wrote in message
news:43**************************@posting.google.c om...
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



Nov 13 '05 #5
Hello Ottar,

No solutions to your problem, just a couple of comments on NG etiquette
1. Cross posting is considered rude, not everone are subscribed to the same
groups you are, so they get messages about groupos that could not be
resolved..
2. Sarcasm usually backfires. You are asking for help, annoying your
potential helpers is also rude.
3. Copying previous post is not neccessary, it just wastes space on the news
server.

Ragnar
Nov 13 '05 #6
My appologies for breaking NG etiquette ! !
Regarding crossposting, I was not sure which group the problem belonged to.
Next time I'll post individually.
Regarding copying previous post, yes I agree in general, but it was done to
clarify (at the bottom is Outlook Express default).
Reagrding sarcasm, again you are right, but beeing called stupid:
1. Why are you trying to open 2,000 external instances of a Mapi session

in succession? It seems a pointless test - except to find out where the
stupidity point is. 380 sounds pretty good.

for asking relevant questions tickled my humor nerve... Again I'm sorry.

I've not found a solution for my problem yet, and I've tested on several
PC's. Anyone know how to report bug's to Microsoft?

Ottar
Nov 13 '05 #7
"Ottar L. Osen" <la*************@earthling.net> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl
My appologies for breaking NG etiquette ! !
Regarding crossposting, I was not sure which group the problem
belonged to. Next time I'll post individually.


No, please don't! *If* you have determined that multiple newsgroups are
relevant to your question (they usually aren't, but may be), then it is
much better -- and generally accepted -- to crosspost to those groups in
a single message, rather than post the same message independently to
multiple groups. Most newsreader programs recognize crossposts, so that
if a user marks your message as read in one group, the message will also
be marked as read in any crossposted groups. Also, replies to the
crossposted message appear in all groups, so that readers (and you) can
tell whether a question has been answered or not.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
4
by: Ottar | last post by:
Error: 80040108 after 380 CreateObject("MAPI.Session") Function MAPI_Test2() Dim i As Integer Dim MySession As MAPI.Session i = 0 While (i < 2000) Set MySession =...
14
by: dale zhang | last post by:
Hi groups, Can anyone give me the equivalent C# sharp code for this VB.ET code, :: VB.NET :: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles...
1
by: Axel Dahmen | last post by:
Hi, today I've had a strange DTS error: In one of my transformations I'd been using several Copy Column transformations + one ActiveX transformation using a lookup function. This lookup function...
10
by: thomson | last post by:
Hi, i create a session variable in C# as follows Session , but iam not able to access the variable in VB.net like intmode=Session("var"); Why is that ? Regards
2
by: mik.sjoblom | last post by:
Hello, I have developed a Access application that needs to read mail from Outlook, versions on Access and outlook are 2003. In the code i use mapi to connect to outlook. When i tries to read the...
3
by: Paul | last post by:
Hi All, In my application, I wished to check certain things on each page load, so rather than paste the same code in each pages constructor, I thought it would be more logical to inherit from...
0
by: PShark | last post by:
Hi I have a VB6 app that uses MAPI to send and receive emails. My users are able to use the app to send emails successfully, but when there are new emails in the mailbox, the program opens the email...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.