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 (???).

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵