message && $this->store) { // Get addressbook for current session $addrBook = $GLOBALS['mapisession']->getAddressbook(); // get message properties. $messageProps = mapi_getprops($this->message, [PR_SUBJECT]); // Read the appointment as RFC2445-formatted ics stream. $appointmentStream = mapi_mapitoical($GLOBALS['mapisession']->getSession(), $addrBook, $this->message, []); if ($appointmentStream === false) { throw new RuntimeException('Unable to convert appointment'); } $filename = (!empty($messageProps[PR_SUBJECT])) ? $messageProps[PR_SUBJECT] : _('Untitled'); $filename .= '.ics'; $this->setNecessaryHeaders($filename, strlen($appointmentStream)); $split = str_split($appointmentStream, BLOCK_SIZE); foreach ($split as $s) { echo $s; } } } /** * Generic function to check received data and download ics file. */ public function download() { $this->downloadAppointmentAsFile(); } } // create instance of class to download message as file $messageInstance = new DownloadAppointment(); try { // initialize variables $messageInstance->init($_GET); // download message $messageInstance->download(); } catch (Exception $e) { $messageInstance->handleSaveMessageException($e); }