Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsWindows Server 2003Windows 2000Windows NTSmall Business ServerVirtual ServerExchange ServerIISHost Integration ServerISA ServerSMSWSUSMOMWindows Media ServerSecurityCertification
Related Topics
SQL ServerMS WindowsMS OfficePC HardwareMore Topics ...

Windows Server Forum / Exchange Server / Applications / October 2005

Tip: Looking for answers? Try searching our database.

URGENT - PLEASE Problem With Exchange 2000 and Visual Basic

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jose Enrique - 14 Oct 2005 14:12 GMT
Hello,
My name is Jose and I'm programming with Visual Basic 6.0. I have a program
which access to two mailboxes in a Exchange 2000 server to get the
appointments.

The process is the following,
it opens a session with CDO, it applies a filter to get the appointments
which starts 7 days before now and ends 7 days after now. It gets the first
appointment which matchs with the present moment. Then it closes the session
and It waits 5 minutes to repeat the process with the 2 mailboxes.

But  I have a BIG problem,
It works ok the first time but the second time it tries to logout the first
mailbox it have the error: "-2147417848 Method '~' of object '~' failed".
Then when It tries to access to the appointments to the second mailbox it
have the error: "-2147417848 Method '~' of object '~' failed". The next time
it tries to access to the appointments of the first mailbox the program have
a global error and it ends.

I don't know why the program fail the second time it access to the mailboxes
and it crackes the third time.
I would be very grateful if anyone could help me because I don't find a
reason and a solution.
Dan Mitchell - 14 Oct 2005 18:51 GMT
> I don't know why the program fail the second time it access to the
> mailboxes and it crackes the third time.

What does your code look like? (Ideally, what's the smallest sample of
code you can show us that has this problem).

What happens if you change the code and don't log out between checks?
That's probably a better idea in the long run, because some versions of
CDO have a memory leak when you log in and out.

-- dan
José Enrique Aguado - 14 Oct 2005 20:27 GMT
Hello Dan. Thanks for answer me.
I'm Jose Enrique and I'm writing from my home.

I dont't remember exactly the code because I'm not in the office but I try
to write you the code I remember. Nex monday I write you the exact code: Do
you find any error?

Global process:

While not g_bFin ( the g_bFin variable will be False when the user stop the
service. My program is a NT Service)
   For i=0 to iUsers-1
       bCheck = bCheckMailbox(ExchangeAlias(i))
   next
   lTime = Timer
   While Timer <= lTime + 30000
       DoEvents
   Wend
Wend

I don't remember exactly de code - the new monday I write you the exact
code:

Function bCheckMailBox(BVal cAlias as string)  as Boolean

   (variables declaration)
   ....

   On Error Goto ErrorPoint:

   Set ObjSesion = new Session
   ObSesion.Logon cAlias
   Set ObjCalendar =
objSession.GetDefaultFolder(MAPI.CdoDefaultFolderCalendar)
   Set ObjColAppointments =  objCalendar.Messages
   Set ObjFilter = ObjColAppointments.Filter
   objFilter.Fields.Add CdoPR_START_DATE, Now-7
   objFilter.Fields.Add CdoPR_END_DATE, Now+7

   cNow = Format$(Now,"yyyymmdd hhnnss")
   For each ObjAppointment in ObjColAppointments
       cState =  ObjAppointment.BusyStatus
       cStartDate = Format$(ObjAppointmen.StartDate,"yyyymmdd hhnnss")
       cEndDate = Format$(ObjAppointment.EndDate,"yyyymmdd hhnnss")
       If cStartDate <= cNow And cEndDate>=Now then
           cUserState = cState
           cUserStart  = cStartDate
           cUserEnd = cEndDate
           Exit for
       endIf
   Next
   Set ObjCalendar = Nothing
   Set objColAppointments = Nothing
   Set ObjFilter = Nothing
   ObjSession.Logout

   bCheckMailBox = True

   Exit Function

ErrorPoint:
   bCheckMailBox = False
   Set ObjCalendar = Nothing
   Set objColAppointments = Nothing
   Set ObjFilter = Nothing
   ObjSession.Logout
End Function
Dan Mitchell - 14 Oct 2005 21:43 GMT
>         bCheck = bCheckMailbox(ExchangeAlias(i))

What does ExchangeAlias() return? Are you using dynamic profiles here
(profileInfo parameter to Logon())? If so, then that might be confusing
things.

It would also be useful to check if you have the same problems running
your app as a normal app rather than a service.

Otherwise, the code looks fine, you're logging in and out and cleaning
objects up and everything that you should be doing, so it's not obvious
what the problem is, sorry.

-- dan
José Enrique Aguado - 14 Oct 2005 22:12 GMT
I don't remember the exact code to logon. I only remember it only use the
name of user in Exchange.
If you want I write the exact code next monday when I arrive to the office.
Could you look this part when I put the code?

Again thanks for your help

José Enrique
Jose Enrique - 17 Oct 2005 07:57 GMT
Hello,
I'm Jose Enrique again. What about the weekend?

The exact code for login,

strProfileInfo = g_cServidorExchange & vbLf & cNombreExchange

ObjSession.Logon "", "", False, True, 0, True, strProfileInfo
Dan Mitchell - 17 Oct 2005 16:30 GMT
"Jose Enrique" <eaguado@jusan.es> wrote in news:uWgh8fu0FHA.3188
@TK2MSFTNGP14.phx.gbl:
> The exact code for login,
>
> strProfileInfo = g_cServidorExchange & vbLf & cNombreExchange
>
> ObjSession.Logon "", "", False, True, 0, True, strProfileInfo

That code is fine, so -- does it have the same problems if you run as a
normal app rather than a service? Does it make a difference if you
restructure your code to log in once to each session (so you'd have two
session objects), then check the calendars every five minutes and stay
logged in all the time?

There's nothing obviously wrong with your code, unfortunately, so there's
no easy solution. Have you applied all the relevant service packs to the
Outlook/Exchange installed on that machine?

-- dan


Jose Enrique - 18 Oct 2005 08:05 GMT
Thanks Dan,

I have modified the program. I open the sessions in the beginning of the
program and I close them when the program is stopped. I put the new version
version yesterday at 15:00 PM and today the program is still running. It
seems that this can be the solution. I tell you if all is ok.

About the service packs, it's a difficult subject. I'm programming in Spain
and the program is running in Norway. It is difficult knowing if an user has
all the service pack installed...

Again thanks for your solution and thanks for spending your time helping me
and I tell you about the program. I hope this solution will be the right
one. if I can help you in something tell me. My personal email es
jeaguado@wanadooadsl.net and my business email es eaguado@jusan.es.

José Enrique
Dan Mitchell - 19 Oct 2005 01:04 GMT
> I have modified the program. I open the sessions in the beginning of
> the program and I close them when the program is stopped. I put the
> new version version yesterday at 15:00 PM and today the program is
> still running. It seems that this can be the solution. I tell you if
> all is ok.

Okay, that's good news. I'm not sure why the problem was happening, but
this should be a solution.

> Again thanks for your solution and thanks for spending your time
> helping me and I tell you about the program.

No trouble -- glad to help!

-- dan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.