title: Creating ICS for Outlook Meeting Event using PHP
body: <p>Attempting to generate .ics from php, unsuccessfully thus far. The file is created (it downloads to my /downloads folder) but when I click on the downloaded ics event, nothing happens, no popup in Outlook. Here's what I tried:</p>
  
  <pre><code>$company='company';//$_GET['company'];
  $proj_title='projtitle';//$_GET['proj_title'];
  $proj_num='project number';//$_GET['proj_num'];
  $subject='subject';//$_GET['subject'];
  $subject=$proj_num.' '.$company.' - '.$proj_title.': '.$subject;
  
  $http='http%3A%2F%2F';
  $fwd_slash='%2F';
  $question_mark='%3F';
  $equals='%3D';
  $ampersand='%26';
  
  $description='Brief description of meeting.';
  
  /* begin ical */
  $meeting_date=date('Y-m-d')." 09:00:00";
  $meeting_duration=3600;
  
  $meeting_stamp=strtotime($meeting_date." UTC");
  $dtstart=gmdate("Ymd\THis\Z",$meeting_stamp);
  $dtend=gmdate("Ymd\THis\Z",$meeting_stamp+$meeting_duration);
  
  /* set up the event properties */
  $event=array(
      'id'          =&gt; $proj_num,
      'subject'     =&gt; $subject,
      'description' =&gt; $description,
      'datestart'   =&gt; $dtstart,
      'dateend'     =&gt; $dtend,
      'location'    =&gt; 'Boardroom'
  );
  
  /* build the ics file */
  $ical='BEGIN:VCALENDAR
  VERSION:2.0
  PRODID:-//hacksw/handcal//NONSGML v1.0//EN
  CALSCALE:GREGORIAN
  BEGIN:VEVENT
  DTEND;TZID="America/New_York":'.$dtend.'
  UID:'.md5($event['subject']).'
  DTSTAMP:'.time().'
  LOCATION:'.addslashes($event['location']).'
  DESCRIPTION:'.addslashes($event['description']).'
  URL;VALUE=URI:http://tracker/ics/'.$event['id'].'
  SUMMARY:'.addslashes($event['subject']) . '
  BEGIN:VALARM
  TRIGGER:-PT30M
  REPEAT:1
  DURATION:PT15M
  ACTION:DISPLAY
  DESCRIPTION:Reminder
  END:VALARM'.'
  DTSTART;TZID="America/New_York":'.$dtstart.'
  END:VEVENT
  END:VCALENDAR';
  
  /* set correct content-type-header */
  if($event['id']){
      header('Content-type: text/calendar; charset=utf-8');
      header('Content-Disposition: attachment; filename=tracker_event.ics');
      echo $ical;
  }
  else{
      header('Location: /');
  }
  </code></pre>
  
  <p>I am relatively new to icalendar events and such, exhaustively researched online to come up with the code presented above, had some mild success using dummy values, until now I need to substitute with real data.</p>
  
  <p>Any help is greatly appreciated.</p>