Outlook SyncObjects in Delphi 5

Is there a way to access Outlook's SyncObjects in Delphi 5?
(I am trying to force the Send/Receive command without opening Outlook. The solutions I have seen that involve accessing Explorer.CommandBars don't seem to work for me).
I have tried:
var
  OutApp   : TOutlookApplication; {placed on the form so instantiated}
  NmSpace : NameSpace;
  K              : LongInt;
begin
  NmSpace := OutApp.GetNamespace('MAPI');
  NmSpace.Logon('', '', False, False);
  for K:=1 to NmSpace.SyncObjects.Count do...
    {compiler says SyncObjects is "undeclared identifier"}
  for K:=1 to OutApp.Session.SyncObjects.Count do...
   {compiler says Session is "undeclared identifier"}
end;

I have found people on-line saying both of these ways of accessing SyncObjects, but I suspect they are using later versions of Delphi than Delphi 5.
OnionsingerAsked:
Who is Participating?
 
jimyXConnect With a Mentor Commented:
>   "SyncObjects & Session is "undeclared identifier""

It could be a shortage in D5. Your code works just fine in D7. I do not have D5 to try that.

Another way and also works fine in D7:
uses ComObj;
...
var
  OutApp, NmSpace : OLEVariant;
  K : LongInt;
begin
  OutApp := CreateOleObject('outlook.application');
  NmSpace := OutApp.GetNamespace('MAPI');
  NmSpace.Logon('', '', False, False);
  for K:=1 to NmSpace.SyncObjects.Count do...
    {compiler says SyncObjects is "undeclared identifier"}
  for K:=1 to OutApp.Session.SyncObjects.Count do...
   {compiler says Session is "undeclared identifier"}
  NmSpace := Unassigned;
  OutApp := Unassigned;
end;

Open in new window


You may try OfficePartner in case it solves the problem:
http://sourceforge.net/projects/tpofficepartner/

But I think upgrading to a newer version of Delphi is going to help you programming better.
0
 
OnionsingerAuthor Commented:
Thank you for the comment, but I don't plan to upgrade to Delphi 7.  I am trying to find out if there is a way to achieve this using Delphi 5.
0
 
jimyXCommented:
Will try to help as much as I can, but I do not have D5 to test.

Please check the units included in your project, and make sure to include "Outlook8" in the uses clause.

For more information about using Outlook in D5 refer to this page:
http://www.djpate.freeserve.co.uk/AutoOutl.htm
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
OnionsingerAuthor Commented:
Outlook8 is in my uses clause.
I already read the page you linked to, but it doesn't cover the topic of SyncObjects.
0
 
jimyXCommented:
Could be shortage in D5. Because since you did include all the necessary units to your project and it's still not identified, then that means D5 lacks some objects.
0
 
OnionsingerAuthor Commented:
It turns out that using:
try
  Outlook:=GetActiveOleOjbect('Outlook.Application')
except
  Outlook := CreateOleObject('Outlook.Application');
end;
 (instead of placing a TOutlookApplication on the form)
NmSpace:=Outlook.GetNameSpace('MAPI')
allows me to then access NmSpace.SyncObjects
even in Delphi 5 so this solves the problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.