473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug in Access 2003 ? Error after 380 CreateObject("M API.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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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(Sess ion As MAPI.Session) As Boolean
Set Session = CreateObject("M API.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administra tor"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function

Function MAPI_Logoff(Ses sion 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 4194
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("M API.Session")
OK = MAPI_Logon(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

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

Ron W

"Ottar" <la*****@earthl ing.net> wrote in message
news:43******** *************** ***@posting.goo gle.com...
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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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(Sess ion As MAPI.Session) As Boolean
Set Session = CreateObject("M API.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administra tor"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function

Function MAPI_Logoff(Ses sion 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("M API.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthl ing.net> wrote in message
news:43******** *************** ***@posting.goo gle.com...
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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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(Sess ion As MAPI.Session) As Boolean
Set Session = CreateObject("M API.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administra tor"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function

Function MAPI_Logoff(Ses sion 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******** ******@TK2MSFTN GP11.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("M API.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthl ing.net> wrote in message
news:43******** *************** ***@posting.goo gle.com...
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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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(Sess ion As MAPI.Session) As Boolean
Set Session = CreateObject("M API.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administra tor"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function

Function MAPI_Logoff(Ses sion 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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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.w ave.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******** ******@TK2MSFTN GP11.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("M API.Session")
Debug.Print i
i = i + 1
Set MySession = Nothing
DoEvents
Wend
End Function

Any other ideas?

Best regards

Ottar

"Ottar" <la*****@earthl ing.net> wrote in message
news:43******** *************** ***@posting.goo gle.com...
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("M API.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(MySe ssion)
If OK Then OK = MAPI_Logoff(MyS ession)
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(Sess ion As MAPI.Session) As Boolean
Set Session = CreateObject("M API.Session")
On Error Resume Next
Session.Logon , , , , , , "my-server" & vbLf & "Administra tor"
If Err.Number <> 0 Then MAPI_Logon = False Else MAPI_Logon = True
End Function

Function MAPI_Logoff(Ses sion 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******** ******@TK2MSFTN GP09.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
3658
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
5036
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 = CreateObject("MAPI.Session") Debug.Print i
14
5912
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 MyBase.Load 'This event routine in the loginCheck user control fires when the
1
2248
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 uses a second connection to the same SQL server but to a different database. I'm using this function to populate a new column in a table with calculated values. The transformation didn't run, I got an "Transaction context in use by another...
10
2395
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
10518
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 subject of a message outlook displays "A program is trying to access e-mail adresses you have stored in Outlook. Do you want to allow this." And then i can allow access for max 10 minutes. My application is use scheduled statupm creating reports...
3
34466
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 Page and place the code in there. Then each webpage will inherit from my modified page class. This works fine, but if I try and access the Session from the modified page class, I get the following error: Session state can only be used when...
0
2351
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 but then raises the following error: "Automation error – The object invoked has disconnected from its clients." The same program is installed on over 30 workstations which have roughly the same config Windows Xp and outlook 2003. The error is...
3
16030
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 and the fields were populated properly, when I added all the rest, it wouldn't run and even when I tried to go back, it still won't run now...I am getting the following error message: "Either BOF or EOF is True, or the current record has been...
0
8675
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.