I’m working on project, which main goal is synchronization between outlook’s calendar and our application’s calendar. In our application, we are using custom programming language and we are mapping outlook functions through dispatchId.
And here comes my problem. I’m using StorageItem in Outlook calendar for saving some internal data, but when I try to call GetStorage method, from time to time it ends with Exception.
Exception message is “Incorrect function” (its translated from czech “Nesprávná funkce”).
I’m calling GetStorage in different folders (calendars), in different data stores (.pst). When I try to call GetStorage method right from vsto addin, it works everytime. But calling it within our app through COM, its just pain.
I cannot induce exact behavior, it looks like it happens randomly.
Syntax:
oFolder := oNS.GetFolderFromID(OFolderID,''); // ok, folder found
if oFolder <> nil then begin
oStorageItem := oFolder.GetStorage('Synchronization.Info', 0); // exception
if oStorageItem.Size > 0 then
Result := False;
end;
Example situation:
First datastore:
- calendar called “firstCal”
- calendar called “secondCal”
Second datastore:
- calendar called “thirdCal”
Calling getStorage:
- calling firstCal.GetStorage – Exception
- calling secondCal.GetStorage – ok
- calling thirdCal.GetStorage – ok
.. and other random combinations
I’ve finally found a solution thanks to this thread http://www.delphigroups.info/2/11/941254.html.
“Delphi raises an error it is anything but S_OK (0), but VB(Visual Basic) checks if it is>0 (that’s what SUCCEEDED macro/function does).”
Our custom language is based on Delphi. GetStorage function call result was 1, and we were expecting S_OK (0) if call was ok.