Outlook fails to recognize an ics message

自古美人都是妖i 提交于 2019-12-02 10:55:44

问题


I am trying to create an .ics file in PHP that is mailed to the user. The solution works well in Gmail (I get a fancy invitation with all information appearing in the right places), but Outlook does not seem to recognize it at all. I receive an empty email with no attachment and no event is added to any calendar as far as I can see.

I suspect the problem lies somewhere in the headers, but I have very little experience with mail protocols and can't pinpoint it. I've been fiddling with this all day, please help :(

Update: for some weird reason I do get the invite and it shows as attachment on iPhone which is synced with my Exchange account. It is the desktop Outlook that fails. Why?

Here is the code in all it's glory.

$message = 
"BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN
METHOD:REQUEST
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP: $timestamp
DTSTART: $datestart
DTEND: $dateend
UID: $uniqueid
LOCATION: $address
DESCRIPTION: $description
URL;VALUE=URI: $uri
SUMMARY: $summary

END:VEVENT
END:VCALENDAR";

// Mail parameters
$newline = "\r\n";

$headers = "From: InnovationskontorEtt Dashboard <admin@innovationskontorett.se>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; charset=utf-8; name=inbjudan.ics; method=REQUEST".$newline; 
$headers .= "Content-Disposition: inline; filename=inbjudan.ics".$newline;
$headers .= "Content-Transfer-Encoding: 7bit";

$subject = $summary;

$to = 'maija.vilkina@liu.se';

/*mail send*/
if(mail($to, $subject, $message, $headers)) : ?>
      <div class="alert alert-warning">
        Evenemanget skickades till din kalender.
      </div>

<?php else : ?>
      <div class="alert alert-danger">
        Det gick inte att skicka evenemanget till din kalender.
      </div>
<?php endif; ?>

回答1:


In general, it is a best practice to at least send a multipart/alternative so that clients that dont know anything about the text/calendar format can show a readable message to the user. See http://tools.ietf.org/html/rfc6047#section-4.2 for an example.

Then, for an invitation to be an actual invitation it needs to have at least one ORGANIZER and one ATTENDEE property. See http://tools.ietf.org/search/rfc5546#section-3.2.2 for the list of mandatory properties. This should fix your issue.

Finally, showing us the actual MIME message that is sent would be more useful than showing code, at least as far as detecting interop issues with Outlook.



来源:https://stackoverflow.com/questions/21812438/outlook-fails-to-recognize-an-ics-message

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