View Full Version : Looping calendar entries in Outlook
oz8hp
08-20-2009, 07:11 AM
I am creating a plugin for my Outlook that loops all my calendar entries and reads thoose that has a given category.
I first loop all the entries to find all the categories - no problems and no security warning
I then make a filter on dateinterval and loop the found entries and check if the right category. If so I take some of the information and write to a stringlist properly formated to be a iCalender lookalike - but this action results in Outlook showing the 'Another program is trying....' warning and that really makes me crazy.
How to avoid this? any samples out there.
oz8hp
08-20-2009, 07:14 AM
My code looks like this
ItemSelected = check if category is selected
There are some other helper function for formating the text, but I think you can see the idea
procedure TfrmMain.ExportCalender;
var
Outlook : OLEVariant;
NameSpace : OLEVariant;
myAppts : OLEVariant;
appt : OLEVariant;
i : integer;
startdate : String;
enddate : String;
filter : string;
vAppts : TStringlist;
begin
vAppts := TStringList.Create;
startdate := FormatDateTime('dd/mm/yy hh:nn am/pm', picDate.Date);
enddate := FormatDateTime('dd/mm/yy hh:nn am/pm', picDate.Date + 365);
filter:='([Start] >= "' + startdate + '") AND ([Start] <= "' + enddate + '")';
Try
Outlook := GetActiveOleObject('Outlook.Application');
except
Outlook := CreateOleObject('Outlook.Application');
end;
NameSpace := outlook.GetNameSpace('MAPI');
myAppts := NameSpace.GetDefaultFolder(olFolderCalendar).items ;
MyAppts.IncludeRecurrences := True;
myAppts := MyAppts.Restrict(filter);
myAppts.Sort('start');
vAppts.Add('BEGIN:VCALENDAR');
vAppts.Add('CALSCALE:GREGORIAN');
vAppts.Add('VERSION:2.0');
appt := myAppts.GetFirst;
for i := 1 to MyAppts.count do
Begin
If ItemSelected(appt.Categories) = True Then
Begin
vAppts.Add('BEGIN:VEVENT');
If appt.Sensitivity = olNormal Then
vAppts.Add('CLASS:PUBLIC')
Else If appt.Sensitivity = olConfidential Then
vAppts.Add('CLASS:CONFIDENTIAL')
Else
vAppts.Add('CLASS:PRIVATE');
If Length(appt.Body) > 0 Then
vAppts.Add(WrapText('DESCRIPTION:' + RemoveCR(appt.Body), WrapPos));
vAppts.Add('DTEND:' + FormatICalDateTime(appt.End));
vAppts.Add('DTSTART:' + FormatICalDateTime(appt.Start));
vAppts.Add('LAST-MODIFIED:' + FormatICalDateTime(appt.LastModificationTime));
If (Length(appt.Location) > 0) Then
vAppts.Add(WrapText('LOCATION:' + appt.Location, WrapPos));
vAppts.Add(WrapText('SUMMARY:' + appt.Subject, WrapPos));
vAppts.Add('UID:' + appt.EntryID);
vAppts.Add('END:VEVENT');
End;
appt := MyAppts.getnext;
End;
vAppts.Add('END:VCALENDAR');
SaveFile(vAppts);
vAppts.Free;
outlook := UnAssigned;
end;
MarkFillipos
03-21-2010, 12:32 PM
I try to write all down I wrote already.our customer is using axigen with outlook connector and nokia mobiles with mail for exchange.All Items are displayed in the web mail calendar but aren
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.