Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Make iCal subscribable calendar from Exchange data' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Make iCal subscribable calendar from Exchange data
Authored by: Ptitboul on Jan 22, '08 04:41:04AM

Another approach could be to use Mail.app to connect to the IMAP server, and to browse the Calendar.imapbox/Messages directory in ~/Library/Mail to extract the calendar information and create the ics file.
Did anyone implement this approach?



[ Reply to This | # ]
Make iCal subscribable calendar from Exchange data
Authored by: Ptitboul on Jan 23, '08 02:07:36PM
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;
}


[ Reply to This | # ]
Make iCal subscribable calendar from Exchange data
Authored by: Ptitboul on Sep 05, '08 05:08:58AM
the script is missing an element. You have to replace
  while () {
with
  while (<FILE>) {


[ Reply to This | # ]