473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 4173
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.