Link to home
Start Free TrialLog in
Avatar of Stef Merlijn
Stef MerlijnFlag for Netherlands

asked on

Delphi: Connect to running MS Outlook

Hi,

Following code I use to connect with MS Outlook.
When trying to connect to a running instance of Outlook I get an EOleSysError:
NL: Uitvoeren vanaf de server is mislukt, ProgID: "outlook.application".
US: Server execution failed, ProgID: "outlook.application". Ā << translated
  try
    Outlook := GetActiveOleObject('outlook.application');  << ERROR
    Result     := True;
  except
    Outlook := CreateOleObject('outlook.application');    << THIS WORKS
    Result     := True;
  end;

Open in new window

Any ideas how to solve this?
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Can you check if everything matches and you've set up everything, like the outlook connection?
multiple instances of Outlook aren't allowed

const
  olMailItem = 0;
var
  Outlook: OLEVariant;
  MailItem: Variant;
  MailInspector : Variant;
  stringlist : TStringList;
begin
  try
   Outlook:=GetActiveOleObject('Outlook.Application') ;
  except
   Outlook:=CreateOleObject('Outlook.Application') ;
  end;

Open in new window


Also a similar case on EE
https://www.experts-exchange.com/questions/28933412/Can't-connect-to-Outlook-via-TOutlookApplication-component.html
Avatar of Stef Merlijn

ASKER

@extermie:
Your code is the same as mine, so that isn't the problem.
The similar case you mentioned has a solution in case Outlook is still running in the background (in stead of being closed), but it doesn't solve the problem to connect to a running instance.
ASKER CERTIFIED SOLUTION
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!
Your suggestion also pointed met to RapWare, which doesn't need a connection to Outlook itself.