dongliu1883 2017-04-06 08:07
浏览 63
已采纳

Outlook-web-app不会从我生成的icalendar中导入事件

For my application I use laravel 5.3 and a package called markuspoerschke/iCal which you can find here.

When a student wants to subscribe to his or her calender, we generate an URL which can be filled into Google Calender and Outlook. Except the last mentioned outlook it isn't importing any events.

Example of how our generated ICS looks like. This contains 1 event with the description of 'test'.

BEGIN:VCALENDAR 
VERSION:2.0 
PRODID:www.onderwijsonline.nl 
X-PUBLISHED-TTL:PT15M 
BEGIN:VEVENT 
UID:58e5f21fc2551 
DTSTART;TZID=Europe/Amsterdam:20170406T090000 
SEQUENCE:0 
TRANSP:OPAQUE DTEND;TZID=Europe/Amsterdam:20170406T140000 URL:http://oo.dev/calendar/event/420 
SUMMARY:Test 
CLASS:PUBLIC 
DTSTAMP:20170406T094535Z 
END:VEVENT 
END:VCALENDAR

The script that calls the package to generate this:

public function getIcal($token = null)
    {
        $user = $this->userRepository->getByToken($token);

        $vCalendar = new \Eluceo\iCal\Component\Calendar('www.onderwijsonline.nl');
        $vCalendar->setPublishedTTL('PT15M');

        if (!is_null($user)) {

            /**
             * Calendar events
             */
            $events = $this->calendarRepository->getEventsForUser($user->id, Carbon::now()->subWeeks(2), Carbon::now()->addWeeks(6));
            foreach ($events as $event) {

                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setDescription($event['description'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Project events
             */
            $events = $this->calendarRepository->getEventsForProjects($user->id, null, null);

            foreach ($events as $event) {
                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setUrl($event['href'])
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }

            /**
             * Timetable events
             */
            $events = $this->calendarRepository->getEventsForTimetables($user->id, Carbon::now()->subWeeks(2), Carbon::now()->addWeeks(6));
            foreach ($events as $event) {
                $vEvent = new \Eluceo\iCal\Component\Event();

                $vEvent
                    ->setUseTimezone(true)
                    ->setUseUtc(false)
                    ->setDtStart(Carbon::parse($event['start']))
                    ->setDtEnd(Carbon::parse($event['end']))
                    ->setNoTime(($event['allDay'] == 1 ? true : false))
                    ->setSummary($event['title']);

                $vCalendar->addComponent($vEvent);
            }
        }

        header('Content-Type: text/calendar; charset=utf-8');
        header('Content-Disposition: inline; filename=onderwijsonline.ics');

        return $vCalendar->render();
    }

As I've mentioned above, this exact setup works fine for Google Calendar, but is not for outlook.

Does anyone know why and how that can be fixed?

  • 写回答

1条回答 默认 最新

  • doumin4553 2017-04-21 09:54
    关注

    You are using a TZID=Europe/Amsterdam but your ics file does not include the VTIMEZONE definition corresponding to this TZID. So before your BEGIN:VEVENT, you should have a BEGIN:VTIMEZONE...END:VTIMEZONE component.

    As far as why it still works for Google but not for Outlook: A lot of products do use the Olson TZIDs so they can ignore the fact that the VTIMEZONE definition is missing and just assume that your TZID=Europe/Amsterdam corresponds to their mapping.

    Microsoft on the other hand has its own set of TZID identifiers (e.g. "Central Europe Standard Time") and hence can not map your Europe/Amsterdam to a known definition.

    Finally, on stack overflow at least your TRANSP, DTEND and URL property do appear on the same line. I'm assuming that this is just a formatting issue when submitting your question (???).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型