|
danym
Guest
|
Hello!
I have read everything on using OOM from a service and also an old thread in this forum with lots of Microsoft links.
I have had a service in production for a year that waits for events from a database and updates ContactItems and DistListItems in a selected folder.
Upon discovering that my service could not handle server and database restarts properly I set about to rewerite the whole thing.
At this point I have been able to make it work (like a charm, actually) in my test environment. The production version used Redemption but since I now have a license for SecMan and it makes for cleaner code I want to use secman.
App := CreateOleObject( 'Outlook.Application' );
if Assigned ( FOnGetSecurityManager ) then
begin
FOnGetSecurityManager ( OlSecurityManager );
OlSecurityManager.ConnectTo( App.Application );
end;
_NS := App.GetNameSpace('MAPI');
Never mind the FOnGetSecurityManager, it's for modularity purposes. At the line OlSecurityManager.ConnectTo( App.Application ); the delphi debugger stops tracking (when debugging) and the service becomes unresponsive. I have to kill the process.
At one occation I got a confused message from Outlook about changing places to store folders and recreating shortcuts.
I have tried both to create the application instance at service startup and holding it for the lifetime of the ervice and the preferred way of creating and releasing the instance when there is work to do.
My problem is very tricky since I do not have the sources to Security Manager and thus can not trace into it.
I should mention that the CoInitialize and CoUninitialize calls are placed neatly in a try finally block surrounding the SysExecuteService for the worker thread. All in all, as mentioned, it works like a charm when I disable secman.
Any help is greatly appreciated.
Regards,
/Dany
|
|
Posted 05 Jan, 2007 05:43:56
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Dany,
Sorry for the delay. Please try to call the ConnectTo method after calling the _NS.Logon method. If this doesn't help, could you please send me some demo project for testing the issue?
P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
|
|
Posted 08 Jan, 2007 11:32:55
|
|
Top
|
|
danym
Guest
|
Hi Dany,
Sorry for the delay. Please try to call the ConnectTo method after calling the _NS.Logon method. If this doesn't help, could you please send me some demo project for testing the issue?
No problem, thanks for your answer.
I did as you suggest and had similar effects. By chance I let the process run and it turns out that execution was continued after 2 minutes and 30 seconds (a long time in these circumbstanced).
After the execution with the long delay it seems to work regardless of where the connectTo statement is placed.
My guess now is that there was something strange about my own Outlook installation. I will visit my client tomorrow and try my new service there. The big difference is that they have Outlook connected to an Excange server.
If I'm unable to get things working at the site I will put together an example, though it really feels like some Outlook strangeness happended here.
/Dany |
|
Posted 08 Jan, 2007 13:19:00
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Dany,
Ok, I will wait for your test results.
BTW, you can try to get the ActiveExplorer property and try to pass it to the ConnectTo method.
|
|
Posted 09 Jan, 2007 08:10:20
|
|
Top
|
|
danym
Guest
|
Ok, I will wait for your test results.
On site it worked like a charm right away! I'm so happy because I have to go to another client tomorrow and this was eating away at me.
Here ther is Exchange serving Outlook and I login with parameters.
FYI, the call was moved down as far as possible, but I still don't think that has anything to do with anything.
BTW, you can try to get the ActiveExplorer property and try to pass it to the ConnectTo method.
That sounds like a progressive suggestion. Maybe my local (test environment) is more "chatty" because it works with a local Outlook. At the site the Outlook is a client of Excange.
I'll try your last suggestion on the local setup. Since it works in the production site I'll be happy as a frog until I reach a production site where it does not work.
Thanks again and I will report furter.
/Dany |
|
Posted 09 Jan, 2007 10:45:47
|
|
Top
|
|
danym
Guest
|
BTW, you can try to get the ActiveExplorer property and try to pass it to the ConnectTo method.
There is no ActiveExplorer (the property is $00000000 or "Nothing" in VB lingo). Funny thing is that when I try
_FL.GetExplorer
I get similar effects to what I describe above, long time alternated with a stop in the method. I suspect the explorer thing is bringing up dialogs and that is not allowed in the case of services. If the securitymanager is dependent uopn an explorer this is surely the explanation.
Regards,
/Dany |
|
Posted 10 Jan, 2007 04:50:50
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Dany,
There is no ActiveExplorer ...
Sorry, it was my fault, of course the ActiveExplorer property is null in your case.
Do you call the GetExplorer method for the Inbox? If yes, how many folders and items do you have in your Inbox folder?
|
|
Posted 10 Jan, 2007 05:09:50
|
|
Top
|
|
danym
Guest
|
No, I just called the GetExplorer method to try you suggestion. Normally there are no such calls.
I process a Contacts folder. The folder is choosen when the service is set up with another small utility I wrote. It simply calls _NameSpace.PickFolder and stores the reult in the config files.
I have calls to GetNamespace, Logon, GetFolderFromID, _Folder.Items.Add(olContactItem), _Folder.Items.Add(olDistributionListItem), UserProperties (both contact and distributionslists), Delete (both contact and distributionslists). I create a temp mailitem and use the Recipients property to fill a distlist and this is where secman is needed. I also use ItemProperties of the contacts and distlists to change content. That's all.
If you have anything other to try from the top of your head, thats fine and I'll try it as soon as you reply. If not I'll put a small testcase together, but that will have to wait until time allows. And - since it's a problem to the local installation - I'm not sure you will be able to reproduce anyway.
Regards,
/Dany |
|
Posted 10 Jan, 2007 05:19:24
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Dany,
Thank you for the information.
At the moment I have no idea why the code keeps executing after 2 minutes delay on your development PC only. Please let me know if you have any new information.
|
|
Posted 11 Jan, 2007 06:19:35
|
|
Top
|
|