Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Update</strong></p> <p>As No'am rightly commented, Outlook's application COM interface does not support Connect and Disconnect. I was suprised at that, but I normally use the Delphi wrappers and indeed TOutlookApplication's implementation of Connect just returns the result of the CreateOleObject or GetActiveObject. The implementation of TOutlookApplication's Disconnect method, actually does something more than just releasing interfaces. If AutoQuit is true it calls Quit on the Application's COM interface.</p> <p>However, as it seems to be optional, I think not calling olApp.Quit should not cause the problems No'am is having. Leaving my answer as "educational" material and so others don't have to check this.</p> <hr> <p>Not sure this is actually the cause of your problem, but what I miss in your code is the connect to and disconnect from the Outlook Application. Although they apparently are not needed to use the Outlook COM server (as suggested by the mail being sent), they are part of the "normal" COM use patterns I know. I can well imagine that not connecting/disconnecting may well cause finalization code to fall over when that is triggered by the vars going out of scope (after the end statement).</p> <p>The pattern I normally use is:</p> <pre><code>Create / CreateOleObject try Connect try ... finally Disconnect end finally Free / Release end </code></pre> <p>You would use Create and Free when using one of the Delphi provided TxxxApplication wrappers, CreateOleObject and Releasing the interface (setting it to nil/unassigned) if you are using "straight" COM.</p> <p>In your example that would mean adding </p> <pre><code>olApp.Connect; </code></pre> <p>between the CreateOleObject and olNameSpace assignment lines, and adding</p> <pre><code>olApp.Disconnect; </code></pre> <p>after the olNameSpace.LogOff;</p> <p>Adding a couple of try/finally blocks also wouldn't be wasted.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload