ics file not recognized by outlook

走远了吗. 提交于 2019-12-04 05:21:30

问题


I have some problems. I'm trying to send an ics file, so an outlook user can add the event in his calendar. In some versions, like 2010, it works well (home edition) but on some, (like business) it doesn't recognize it directly. You must double-click the content so you can preview it. In that other version, it shows the calendar option immediately as I've clicked the mail.

What am I doing wrong?

Here is the code for the calendar.

$str="BEGIN:VCALENDAR\r\n
PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN\r\n
VERSION:2.0\r\n
METHOD:REQUEST\r\n
X-MS-OLK-FORCEINSPECTOROPEN:TRUE\r\n
BEGIN:VTIMEZONE\r\n
TZID:GTB Standard Time\r\n
BEGIN:STANDARD\r\n
DTSTART:16011028T000000\r\n
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10\r\n
TZOFFSETFROM:+0300\r\n
TZOFFSETTO:+0200\r\n
END:STANDARD\r\n
BEGIN:DAYLIGHT\r\n
DTSTART:16010325T000000\r\n
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3\r\n
TZOFFSETFROM:+0200\r\n
TZOFFSETTO:+0300\r\n
END:DAYLIGHT\r\n
END:VTIMEZONE\r\n
BEGIN:VEVENT\r\n
ATTENDEE;CN=silvian.iosub@gmail.com;RSVP=
 TRUE:mailto:silvian.iosub@gmail.com\r\n
CLASS:PUBLIC\r\n
CREATED:20110803T133418Z\r\n
DTEND:$endtime_ics\r\n
DTSTAMP:20110803T095605Z\r\n
DTSTART:$starttime_ics\r\n
LAST-MODIFIED:20110803T133418Z\r\n
ORGANIZER;CN=\"Silvian Iosub\":mailto:
 silvian.iosub@avira.com\r\n
PRIORITY:5\r\n
SEQUENCE:0\r\n
SUMMARY;LANGUAGE=ro:New Event\r\n
TRANSP:OPAQUE\r\n
UID:".MD5(TIME())."-85d2-69b00dea0ad4\r\n
X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE\r\n
X-MICROSOFT-CDO-IMPORTANCE:1\r\n
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY\r\n
X-MICROSOFT-DISALLOW-COUNTER:FALSE\r\n
X-MS-OLK-AUTOSTARTCHECK:FALSE\r\n
X-MS-OLK-CONFTYPE:0\r\n
BEGIN:VALARM\r\n
TRIGGER:-PT15M\r\n
ACTION:DISPLAY\r\n
DESCRIPTION:Reminder\r\n
END:VALARM\r\n
END:VEVENT\r\n
END:VCALENDAR\r\n";

I am using swift class to send emails; Here are the settings:

$attachment = Swift_Attachment::newInstance()
                            ->setFilename("Invitatie.ics")
                            ->setContentType('text/calendar;method=REQUEST;charset=UTF-8;')
                            ->setBody($str)
                ->setDisposition("inline,filename=".$confDesc.".ics");
        $message2->attach($attachment);

回答1:


Be sure you added this header :

Content-Type: multipart/alternative;

And then for the ics file part :

Content-Type: text/calendar; charset="utf-8"; name="testcal.ics" method=REQUEST'."\r\n";
Content-Disposition: inline; filename="testcal.ics"'."\r\n";

NB : \r\n MUST be between double quotes




回答2:


is

DTEND:$endtime_ics\r\n

actually outputting the endtime or do you have some syntax missing?

also try validating the ics file at http://severinghaus.org/projects/icv/



来源:https://stackoverflow.com/questions/6928264/ics-file-not-recognized-by-outlook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!