View Single Post
  #1  
Old December 6th 07, 12:19 AM posted to microsoft.public.outlook.program_vba
Dan Mitchell
external usenet poster
 
Posts: 58
Default Sender address!!

wrote in
:
The diasbled logout code does not happen to the problem. Enablend/
Disabled makes no difference.
It seems that the problem occours when i access (in any case) the
"Sender" Object up to 4-8 times.


What if you change the logout code to this?

session.Logoff
Set messages = Nothing ' so this is before changing session
Set session = Nothing

(otherwise, the messages object is pointing at a session that's been
cleared out, which might be causing problems).

What makes the difference between the times when it fails after 4 goes
and the times when it fails after 8 goes? How are you calling
GetSenderData?

If I start a new project, add a reference to CDO1.21, and put in this,
it works just fine for me (no logoff, and 100 tries).

Private Sub Form_Load()
For i = 1 To 100
GetSenderData
Next
End Sub

Function GetSenderData()
Dim session As MAPI.session
Dim messages As MAPI.messages
Dim inbox As MAPI.folder

Set session = CreateObject("MAPI.Session")
session.Logon NewSession:=False

Set inbox = session.GetDefaultFolder
(CdoDefaultFolderTypes.CdoDefaultFolderInbox)

Debug.Print inbox.messages(1).Sender.Type ' Crash Line!
End Function


-- dan
Ads