Microsoft Outlook 2016在ICS约会说明中不显示HTML格式。粗体和页眉标记在Outlook 2013中有效,但表无效。
我使用PHP代码创建一个ics文件作为附件,并在X-ALT-DESC; FMTTYPE = text / html中添加了必要的参数和html标签。还试图通过在Outlook 2013中创建约会并将其导出为ics文件来进行逆向工程。
public function download(Request $request)
{
$id = $request->id;
$appointment = Appointment::find($id);//get appointment by id
$start_obj = DateTime::createFromFormat('Y-m-d H:i:s', $appointment->start_time);
$end_obj = DateTime::createFromFormat('Y-m-d H:i:s', $appointment->end_time);
$start = $start_obj->format('Ymd') . 'T' . $start_obj->format('His');
$end = $end_obj->format('Ymd') . 'T' . $end_obj->format('His');
$name = $appointment->reference_code;
$location = $appointment->property->name;
$description = 'Reference Code: ' . $appointment->reference_code . "\\n";
$description .= 'Client: ' . $appointment->client->name . "\\n";
$description .= 'Date & Time of appointment: ' . $appointment->start_time . "\\n";
$html_description = '
<html>
<body>
<table border="1" style="border-collapse: collapse;">
<tr>
<td><b>Reference Code:</b> </td><td style="padding:1em"> ' . $appointment->reference_code . '</td>
</tr>
<tr>
<td><b>Client:</b> </td><td style="padding:1em"> ' . $appointment->client. '</td>
</tr>
<tr>
<td><b>Date & Time of appointment:</b> </td><td style="padding:1em"> ' . $appointment->start_time . '</td>
</tr>
</table>
</body>
</html>
';
//set file header properties. allow for file download
header("Content-Type: text/Calendar; charset=utf-8");
header("Content-Disposition: attachment; filename={$name}.ics");
//set file content
$ics_content = '';
$ics_content .= "BEGIN:VCALENDAR\n";
$ics_content .= "VERSION:2.0\n";
$ics_content .= "PRODID:-//Example/Scheduler//NONSGML {$name}//EN\n";
$ics_content .= "METHOD:PUBLISH\n";
$ics_content .= "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
$ics_content .= "BEGIN:VEVENT\n";
$ics_content .= "CLASS:PUBLIC\n";
$ics_content .= "UID:info@example.com\n";
$ics_content .= "DTSTAMP:{$start}\n";
$ics_content .= "ORGANIZER;CN=info@example.com\n";
$ics_content .= "DTSTART:{$start}\n";
$ics_content .= "DTEND:{$end}\n";
$ics_content .= "LOCATION:{$location}\n";
$ics_content .= "SUMMARY:{$appointment_type} - Appointment Summary {$name}\n";
$ics_content .= "DESCRIPTION:{$description}\n";
$ics_content .= "X-ALT-DESC;FMTTYPE=text/html:{$html_description}\n";
$ics_content .= "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n";
$ics_content .= "X-MICROSOFT-CDO-IMPORTANCE:1\n";
$ics_content .= "X-MICROSOFT-DISALLOW-COUNTER:FALSE\n";
$ics_content .= "X-MS-OLK-CONFTYPE:0\n";
$ics_content .= "BEGIN:VALARM\n";
$ics_content .= "TRIGGER:-PT1440M\n";
$ics_content .= "REPEAT:1\n";
$ics_content .= "DURATION:PT15M\n";
$ics_content .= "ACTION:DISPLAY\n";
$ics_content .= "DESCRIPTION:{$appointment_type} - Appointment Description - {$name}\n";
$ics_content .= "END:VALARM\n";
$ics_content .= "END:VEVENT\n";
$ics_content .= "END:VCALENDAR\n";
return $ics_content;
}
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example/Scheduler//NONSGML test 002//EN
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
UID:info@example.com
DTSTAMP:20190507T130000
ORGANIZER;CN=info@example.com
DTSTART:20190507T130000
DTEND:20190509T150000
LOCATION:23 sdq13
SUMMARY:Inventory & Check Out - Appointment - test002
DESCRIPTION:Reference Code: test furnished002\nClient: Romaguera, Kertzmann and Green\nDate & Time of appointment: 2019-05-07 13:00:00\n
X-ALT-DESC;FMTTYPE=text/html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
N">\n<HTML>\n<HEAD>\n<META NAME="Generator" CONTENT="MS Exchange Server ve
rsion rmj.rmm.rup.rpr">\n<TITLE></TITLE>\n</HEAD>\n
<body>
<table border="1" style="border-collapse: collapse;">
<tr>
<td><b>Reference Code:</b> </td><td style="padding:1em"> test 002</td>
</tr>
<tr>
<td><b>Client:</b> </td><td style="padding:1em"> Romaguera, Kertzmann and Green</td>
</tr>
<tr>
<td><b>Date & Time of appointment:</b> </td><td style="padding:1em"> 2019-05-07 13:00:00</td>
</tr>
</table>
</body>
</HTML>
X-MICROSOFT-CDO-BUSYSTATUS:BUSY
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-CONFTYPE:0
BEGIN:VALARM
TRIGGER:-PT1440M
REPEAT:1
DURATION:PT15M
ACTION:DISPLAY
DESCRIPTION:Inventory & Check Out - Appointment - test002
END:VALARM
END:VEVENT
END:VCALENDAR
预期结果应为MS Outlook的HTML格式(带有表格)事件描述(优先考虑2016)。
任何帮助将不胜感激。