PC Review


Reply
Thread Tools Rate Thread

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

 
 
Ottar
Guest
Posts: n/a
 
      19th Jun 2004
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
 
Reply With Quote
 
 
 
 
Ron Weiner
Guest
Posts: n/a
 
      19th Jun 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Ottar L. Osen
Guest
Posts: n/a
 
      19th Jun 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
CDB
Guest
Posts: n/a
 
      19th Jun 2004
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" <laurits_delete_@earthling.net> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>



 
Reply With Quote
 
Ottar L. Osen
Guest
Posts: n/a
 
      20th Jun 2004
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" <(E-Mail Removed)> wrote in message
news:cb2bfk$ij8$(E-Mail Removed)...
> 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" <laurits_delete_@earthling.net> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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

> >
> >

>
>



 
Reply With Quote
 
Ragnar Midtskogen
Guest
Posts: n/a
 
      21st Jun 2004
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


 
Reply With Quote
 
Ottar L. Osen
Guest
Posts: n/a
 
      22nd Jun 2004
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


 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      22nd Jun 2004
"Ottar L. Osen" <laurits_delete_@earthling.net> wrote in message
news:(E-Mail Removed)
> 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)


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug in Access 2003 ? Error after 380 CreateObject("MAPI.Session") Ottar Microsoft Access 7 22nd Jun 2004 06:58 PM
Error after 380 CreateObject("MAPI.Session") Ottar Microsoft Access 3 20th Jun 2004 06:52 PM
Error after 380 CreateObject("MAPI.Session") Ottar Microsoft Access VBA Modules 3 20th Jun 2004 06:52 PM
Automation error,Unspecified error when using CreateObject("MAPI.Session") Dmitry Streblechenko Microsoft Outlook Discussion 3 21st Oct 2003 10:08 PM
Automation error,Unspecified error when using CreateObject("MAPI.Session") Dmitry Streblechenko Microsoft Outlook Program Addins 2 21st Oct 2003 10:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:43 PM.