Click to See Complete Forum and Search --> : Operation Failed [RESOLVED]
Gensor
Aug 10th, 2005, 09:41 AM
I'm using Outlook via Visual Basic 6
When I use the command :
Set itmClient = otlApp.GetNamespace("MAPI").GetItemFromID(rstClient.Fields("EntryID"))
I get the error "The operation failed"
Sometimes it works and sometimes it fails !
Anybody knows why?
Ecniv
Aug 10th, 2005, 10:23 AM
You will have to do some debugging work to find out why.
I am taking a guess, but if it fails on different records then the entryID is referring to something which no longer exists in the mapi space.
If however it is the same record, but for some reason at different times, perhaps something is stopping the request?
Maybe outlook has new protection which detects when somethiung triesto use it and tries to stop the request. Just guessing really :p
RobDog888
Aug 10th, 2005, 10:48 AM
Its because your trying to retrieve a Public Outlook Object before the public folders have been cached. Its a bug in Outlook. I had this problem when trying to make a startup Add-In that loaded a Public Calendar. It would only work if I clicked the calendar first, clicked somewhere else, then it would display the Public Calendar. :(
Gensor
Aug 10th, 2005, 12:09 PM
Is there anything on Office Update for this bug ?
RobDog888
Aug 10th, 2005, 12:14 PM
No, seems its a issue with the navigation panel on the left side where you can select the folder to view. I tried everything. Time delays, different methods of programmatically initializing the destination folder, monitored the registry to see if there was something I could duplicate to trick it into populating the public cache, etc. :(
That stupid activeX control they use for the navigation is the issue. Seems that it only caches public data on the click or check. :( If you do find something please post back though. I really would like to finish this last feature of my Add-In. :)
Gensor
Aug 10th, 2005, 12:18 PM
I'm using the GetItemFromID function to retrieve the item and modify each time it's modified in a VB Application. Will I have this error each time ?
RobDog888
Aug 10th, 2005, 12:30 PM
If the item is located in a public folder and you have not opened any public folders then it wil. It doesnt matter if you getting an item or folder. :(
Gensor
Aug 10th, 2005, 01:43 PM
I need a solution for this.
The fastest way to retrieve the Item is to use GetItemFromID and it crash each time!!
RobDog888
Aug 10th, 2005, 01:51 PM
But it should only be crashing if Outlook is just been started and the public folder has not been cached yet.
Gensor
Aug 10th, 2005, 02:40 PM
The error occurred even if outlook is open on the public folder where the item is in
Gensor
Aug 10th, 2005, 02:42 PM
This occurs on Outlook 2000.
On Outlook 2003 the error don't occur if Outlook is open on the public folder where the item is in!
Gensor
Aug 10th, 2005, 05:55 PM
That make me sick. I had find the best and fastest way to do the job and now, I'll have to change it until Microsoft create an update for this!
RobDog888
Aug 10th, 2005, 11:55 PM
If you noticed that in the Options of Outlook you can not even set it to startup to a Public folder either. :(
Gensor
Aug 11th, 2005, 07:14 AM
I found a way of doing it!!!
I add the line :
Set folContact = GetFolder(otlApp, "Contacts GRB")
And here's the code of GetFolder
Public Function GetFolder(ByVal otlApp As Outlook.Application, ByVal sFolderName As String) As MAPIFolder
Dim iFolders As Integer
Dim iPublicFolders As Integer
Dim iAllPublicFolders As Integer
Dim folSearched As MAPIFolder
Dim folPublicFolders As MAPIFolder
Dim folAllPublicFolders As MAPIFolder
For iFolders = 1 To otlApp.Session.Folders.Count
If otlApp.Session.Folders.Item(iFolders).Name = "Public Folders" Or _
otlApp.Session.Folders.Item(iFolders).Name = "Dossiers publics" Then
Set folPublicFolders = otlApp.Session.Folders.Item(iFolders)
For iPublicFolders = 1 To folPublicFolders.Folders.Count
If folPublicFolders.Folders.Item(iPublicFolders).Name = "All Public Folders" Or _
folPublicFolders.Folders.Item(iPublicFolders).Name = "Tous les dossiers publics" Then
Set folAllPublicFolders = folPublicFolders.Folders.Item(iPublicFolders)
For iAllPublicFolders = 1 To folAllPublicFolders.Folders.Count
If folAllPublicFolders.Folders.Item(iAllPublicFolders).Name = sFolderName Then
Set folSearched = folAllPublicFolders.Folders.Item(iAllPublicFolders)
End If
Next
End If
Next
End If
Next
Set GetFolder = folSearched
End Function
Gensor
Aug 11th, 2005, 08:38 AM
Forget it... this is only working with Outlook 2003. I still have the error in Outlook 2000 !!! :(
Gensor
Aug 11th, 2005, 09:01 AM
My boss ordered Microsoft Office XP, do you think it's going to work on Outlook XP if it works on 2003 ?
RobDog888
Aug 11th, 2005, 09:22 AM
You can try this way to drill down.
oNS.Folders("Public Folders").Folders("All Public Folders").Folders("Blah")
Gensor
Aug 11th, 2005, 09:26 AM
I guess my only choice now is to put the MDB Contact Id in the ContactItem.User1 and do a loop to find it but it's going to slow it down a lot!
RobDog888
Aug 11th, 2005, 11:11 AM
I just remembered the you could programmatically do an AdvancedSearch but it is only for 2003, I cant remember 100%. I have this thread in CodeBank (http://www.vbforums.com/showthread.php?t=323157).
Gensor
Aug 11th, 2005, 12:07 PM
I only have 1 outlook 2003, all the others are 2000
RobDog888
Aug 11th, 2005, 12:12 PM
This is one of the few things I dont like about Outlook, the way it handles Public Folders and caching. :(
Gensor
Aug 11th, 2005, 03:40 PM
If you're sure that Outlook 2002 and Outlook XP is the same product, so the code I wrote up there is working on Outlook XP too because I found a station with Outlook 2002 on it and I tested my program !
RobDog888
Aug 11th, 2005, 09:06 PM
Outlook XP IS Outlook 2002 OR Outlook 10.0. ;)
Make sure you do an Office Update so all version of Office are updated and the same.
Gensor
Aug 11th, 2005, 09:08 PM
Ok then, so everything is okay for now. I'm sure that users will say that it's too slow for now but I can't do anything else!! And as soon as Office XP (2002) arrives, I install it everywhere and modify my code to add GetItemFromID !
Thanks for your help RobDog.. You're the man! :)
RobDog888
Aug 11th, 2005, 09:19 PM
No problem :) I wish I could get my clients to upgrade as easily as you did. :(
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.