Calendar sync app

Add-in Express™ Support Service
That's what is more important than anything else

Calendar sync app
 
Rafe Aldridge




Posts: 5
Joined: 2007-04-26
Hi,

Just upgraded to the latest VCL Professional.

I've got to write an add-in that "pushes" an Outlook calendar to a remote server (just one way, appointments can only be added/edited/deleted in Outlook). The user can decide what appointments are pushed via the "Label" field in Outlook (e.g. things labeled as "vacation" are pushed but things labelled as "personal" aren't).

To do it the way I'm thinking I need to know:

1) Where to find the current values for the Labels in Outlook
2) How to iterate back 1 month and forward 1 month in an Outlook calendar
3) If there is a unique ID for a calendar entry or a way to flag an entry as pushed (which can be reset if the item is edited)

Initially I was only going to sync on startup, but I might later decide to sync whenever an entry is changed or deleted also?

Any advice would be much appreciated!

Rafe
Posted 26 Apr, 2007 04:48:36 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Rafe,

1) Where to find the current values for the Labels in Outlook

Unfortunately the Label property and Labels collection are not exposed in the Outlook Object Model. But I think they can be accessed via CDO or Extended MAPI.

2) How to iterate back 1 month and forward 1 month in an Outlook calendar

You can use the Restrict method of the Items collection. This method applies a filter to the Items collection, returning a new collection containing all of the items from the original that match the filter.

3) If there is a unique ID for a calendar entry or a way to flag an entry as pushed (which can be reset if the item is edited)


See the EntryID property (unique ID) and the UserProperties collection of the Appointment interface.


P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.

Posted 26 Apr, 2007 06:38:09 Top
Rafe Aldridge




Posts: 5
Joined: 2007-04-26

Thanks for the reply. I've found out that if I install Outlook Redemption I can get access to this property.

Do you know if Add-In Express and Outlook Redemption will sit side-by-side?

Dmitry of Outlook Redemption suggested something like the following:

Const PT_LONG = 3;
Var sItem : OleVariant;
PR_LABEL : integer;
?¬?–??
sItem := CreateOleObject(?¬?–?ŤRedemption.SafeAppointmentItem?¬?–?ť);

PR_LABEL:=sItem.GetIDsFromNames(?¬?–?Ť{00062002-0000-0000-C000-000000000046}?¬?–?ť, $8214);
PR_LABEL := PR_LABEL or PT_LONG;
LabelAsInt := sItem.Fields[PR_LABEL];

But I'm not sure how I get sItem to be the items in my calendar. Sorry if this is all asking too much but its all new to me.

Regards,

Rafe
Posted 27 Apr, 2007 11:30:19 Top
Rafe Aldridge




Posts: 5
Joined: 2007-04-26

Sorry, let me be clearer. I've written the code below which works fine (the Codesite calls just send the data over to the (excellent) Raize Codesite debugging tool).

What I don't understand is how to get SafeAppointmentItem instead of a normal AppointmentItem.

Thanks.


var
CalendarFolder: MAPIFolder;
CalendarItem: AppointmentItem;
Disp: IDispatch;
Loop: Integer;
begin
CalendarFolder := adxDiarySync.OutlookApp.GetNamespace('MAPI').GetDefaultFolder(olFolderCalendar);
for Loop := 1 to CalendarFolder.Items.Count do
begin
Disp := CalendarFolder.Items.Item(Loop);
Disp.QueryInterface(IID__AppointmentItem, CalendarItem);
Codesite.Send('Entry',
'Subject: '+CalendarItem.Subject+#13#10+
'Location: '+CalendarItem.Location+#13#10+
'Start: '+FormatDateTime('dd-mm-yyyy hh:nn:ss', CalendarItem.Start)+#13#10+
'End: '+FormatDateTime('dd-mm-yyyy hh:nn:ss', CalendarItem.End_));
end;
Posted 27 Apr, 2007 12:10:38 Top
Rafe Aldridge




Posts: 5
Joined: 2007-04-26

Speaking to a Delphi colleague yesterday and it turns out he used Redemption in his previous job! Not much, but enough to help me get started so you can ignore my previous questions.

Have now got a proof-of-concept working using Redemption and ADX together.

Thanks for your help.

Rafe
Posted 28 Apr, 2007 03:46:36 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Rafe,

You need to use the Item property of the SafeAppointmentItem object:


  for Loop := 1 to CalendarFolder.Items.Count do begin 
    CalendarFolder.Items.Item(Loop).QueryInterface(IID__AppointmentItem, CalendarItem);
    if Assigned(CalendarItem) then
      try
        sItem := CreateOleObject('Redemption.SafeAppointmentItem'); 
        sItem.Item := CalendarItem;
        // TODO
      finally
        CalendarItem := nil;
      end;
  end; 


Posted 30 Apr, 2007 05:42:36 Top
Rafe Aldridge




Posts: 5
Joined: 2007-04-26

I've got a simple proof-of-concept app working complete with access to the Label property of an AppointmentItem and am very happy.

Many thanks for all your help and, of course, ADX, without which I wouldn't even attempt writing an Outlook Add-In.

Rafe
Posted 30 Apr, 2007 05:58:04 Top