|
|
Make iCal subscribable calendar from Exchange data
It works for me.
Either you can run the following script in a crontab, or (if you have Leopard) you can use the new WatchFolder possibility of launchd.
It creates an ics calendar file that you can subscribe to if you have a web server running on your machine.
#! /usr/bin/perl
sub isUTF8;
my $dir = '/Users/xxxx/Library/Mail/IMAP-xxxx/Calendar.imapmbox/Messages';
my $ics = '/Library/WebServer/Documents/Calendars/outlook.ics';
if ((stat($dir))[9] < (stat($ics))[9]) {
# Nothing to update
exit 0;
}
opendir DIR, $dir or die "opendir $dir: $!";
open ICS, ">$ics" or die "open $ics: $!";
select ICS;
print "BEGIN:VCALENDAR\nVERSION:2.0";
foreach my $msg (readdir DIR) {
open FILE, "$dir/$msg" or die "open $dir/$msg: $!";
while () {
chop;
$events = 1 if /BEGIN:VEVENT/;
next if /^ATTACH:/;
# I have to adjust the TimeZone, I don't know why my Exchange's format
# is not understood by iCal
s|TZID="\(GMT\+01.00\) Sarajevo/Warsaw/Zagreb"|TZID=Europe/Paris|;
s|TZID="GMT \+0100 \(Standard\) / GMT +0200 \(Daylight\)"|TZID=Europe/Paris|;
s|TZID="\(GMT\) Greenwich Mean Time/Dublin/Edinburgh/London"|TZID=Europe/London|;
# Force UTF8 characters.
# If there are Latin1 characters, iCal goes in an infinite loop.
$_ &= "\x7f" x (length $_) unless defined(isUTF8($_));
# Multi-lines
$_ = "\n$_" unless s/^ //;
s/\\N/\\n/g;
push @lines, $_ if $events > 0;
$events = 0 if /END:VEVENT/;
}
close FILE;
my $event = join ('', @lines);
print $event;
undef @lines;
}
print "\nEND:VCALENDAR";
close ICS;
sub isUTF8 {
my $data = shift;
return 1 if $data =~ /(
[\xc0-\xdf][\x80-\xbf]
| [\xe0-\xef][\x80-\xbf]{2}
| [\xf0-\xf7][\x80-\xbf]{3} ) /x;
return undef if $data =~ /([\x80-\xff])/;
return 0;
}
Make iCal subscribable calendar from Exchange data
the script is missing an element. You have to replace
with
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.35 seconds |
|