Delphi Access to Outlook Calendar

Hello,

I have D5 Pro....  I am looking to find a way to read (and maybe write, but DEFINITELY read) an Outlook calendar. I have tried to find a simple, and ideally free component, but to no avail.  I would prefer to stay away from the Outlook Server component, but I may not have any choice.  Who can help?  Sample code or a URL to a free component wins 500 points....

Thanks
George S
gspears060598Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

danielluyoCommented:
CDO or MAPI are not a choice??? they come with Outlook and you can use them to read and write anything Mail Calendar Notes ToDo, etc
0
cqhallCommented:
I read a shared calendar using the Outlook Server component (OutlookApplication) and populate a database with its contents.  The code below is extracted from a working application, but I may have cut a little too deep (missing var, etc)

First you need to establish a namespace and find your folder.  If you are looking for a shared folder, then you can loop through the root folders, its child folders, etc until you find the target folder.

Function TForm1.FindRootFolder(NmSpace: NameSpace; FolderName: string): MAPIFolder;
var
 fldrs: Folders;
 fldr: MapiFolder;
begin
 Fldrs:=nmSpace.Folders;
 fldr:=Fldrs.GetFirst;
 result:=nil;
 While fldr<>nil do
 begin
  if AnsiSameText(fldr.Name,foldername) then // case insensitive match
  begin
   result:=fldr;
   break;
  end;
  fldr:=Fldrs.GetNext;
 end;
end;
 
procedure TForm1.btnFoldersClick(Sender: TObject);
var
 fldrs: Folders;
 fldr: MapiFolder;
 RP: RecurrencePattern;
 RT: olRecurrenceType;
 dt,
 ex_modified,
 ex_created,
 ex_recurStart,
 ex_recurEnd,
 ex_active,
 ex_inactive: tdatetime;
 len : integer;
 subj,
 st: string;

begin
 NmSpace := OutlookApplication1.GetNamespace('MAPI');
 NmSpace.Logon('', '', False, False);
 fldr:=FindRootFolder(NmSpace,'Mailbox - Hall, Charles');
 cnt:=fldr.items.count;
 for i:=1 to cnt do
 try
  application.title:=inttostr(100*i div cnt)+'%';
  application.processmessages;
  if btnBreak.focused then //escape route
  begin
   btnUpdate.enabled:=true;
   btnBreak.enabled:=false;
   exit;
  end;
  Appt:=fldr.Items.Item(i) as AppointmentItem;
  with Appt do
  begin
   subj:=trim(subject);                         // SUBJECT from Exchange
   ex_active:=start;
   ex_inactive:=end_;
   ex_created:=CreationTime;          // TIME_CREATED in Exchange
   ex_modified:=LastModificationTime; // TIME_MODIFIED in Exchange
   if IsRecurring then
   begin
    RP:=GetRecurrencePattern;
    len:=RP.Interval;
    ex_recurStart:=rp.PatternStartDate;
    ex_recurEnd:=rp.PatternEndDate;
    case RP.RecurrenceType of
     olRecursDaily: st:='Daily';
     olRecursWeekly:
     begin
      case rp.DayOfWeekMask of
       olSunday: st:='Sunday';
       olMonday: st:='Monday';
       olTuesday: st:='Tuesday';
       olWednesday: st:='Wednesday';
       olThursday: st:='Thursday';
       olFriday: st:='Friday';
       olSaturday: st:='Saturday';
       else st:='????'
      end;
      st:='Weekly - '+st;
     end;
     olRecursMonthly: st:='Monthly';
     olRecursMonthNth: st:='MonthlyNth';
     olRecursYearly: st:='Yearly';
     olRecursYearNth: st:='YearNth'
     else st:='????';
    end;
    dt:=ex_recurStart;
    repeat
     case RP.RecurrenceType of
      olRecursDaily: dt:=dt+1;
      olRecursWeekly: dt:=dt+7;
      olRecursMonthly: dt:=incmonth(dt,1);
      olRecursYearly: dt:=incMonth(dt,12);
     end;
    until dt>ex_recurEnd;
   end;
  end;
 end;
end;

To add a new appoint, use something like...

   Appt:=devFolder.Items.Add(olAppointmentItem) as AppointmentItem;
   Appt.Subject:=Subject;
   Appt.Location:=Location;
   Appt.Body:=body;
   Appt.Start:=Start;
   Appt.End_:=End_;
   Appt.Duration:=Duration;
   Appt.Categories:=Categories;
   if Appt.IsRecurring then
   begin
     newRP:=RecurrencePattern;
     newRP.PatternStartDate:=PatternStartDate;
     newRP.PatternEndDate:=PatternEndDate;
     newRP.RecurrenceType:=RecurrenceType;
   end;
   Appt.Save;

Chuck Hall
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gspears060598Author Commented:
Outstanding answer.... Apologies for the delay in awarding the points...
GS
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

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.