Solved

Delphi: Connect to running MS Outlook

Posted on 2016-11-11
4
28 Views
Last Modified: 2016-11-17
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?
0
Comment
Question by:Delphiwizard
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:xtermie
ID: 41885244
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
0
 

Author Comment

by:Delphiwizard
ID: 41885329
@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.
0
 
LVL 17

Accepted Solution

by:
xtermie earned 500 total points
ID: 41885386
0
 

Author Closing Comment

by:Delphiwizard
ID: 41891704
Thanks!
Your suggestion also pointed met to RapWare, which doesn't need a connection to Outlook itself.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now