开发者

ics file not recognized by outlook

开发者 https://www.devze.com 2023-03-25 04:20 出处:网络
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 d

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/calen开发者_运维技巧dar;method=REQUEST;charset=UTF-8;')
                            ->setBody($str)
                ->setDisposition("inline,filename=".$confDesc.".ics");
        $message2->attach($attachment);


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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消