PHP:iCal 创建,如何在描述中换行
我正在使用以下内容为 PHP 脚本创建 Outlook 日历邀请。然而 \n 并没有在 Outlook 中给我一个新行。有办法做到这一点吗?如果你不能的话,那就显得很愚蠢了!
function addToCalendar($calEmail, $calSubject, $calDesc)
{
$calEmail = '[email protected]';
$description = $calDesc;
$message="BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20110718T121000Z
DTEND:20110718T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=TOMS TEST:mailto:[email protected]
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Yup:mailto:[email protected]
DESCRIPTION New \n Line
LOCATION: I AM THE LOCATION
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY: TEST SUMMARY
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";
$headers = "From: From Name <From Mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit";
$subject = "Meeting Subject";
$subject = html_entity_decode($calSubject, ENT_QUOTES, 'UTF-8');
if(mail($calEmail, $calSubject, $message, $headers)) {
echo "sent";
}else {
echo "error";
}
}
这是我遇到问题的 DESCRIPTION New \n Line
部分。
将不胜感激任何帮助
汤姆
I'm using the following to create a calendar invite for outlook for a php script. However the \n doesn't give me a new line in outlook. Is there a way to do this? Seems silly if you can't!
function addToCalendar($calEmail, $calSubject, $calDesc)
{
$calEmail = '[email protected]';
$description = $calDesc;
$message="BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20110718T121000Z
DTEND:20110718T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=TOMS TEST:mailto:[email protected]
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Yup:mailto:[email protected]
DESCRIPTION New \n Line
LOCATION: I AM THE LOCATION
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY: TEST SUMMARY
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";
$headers = "From: From Name <From Mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit";
$subject = "Meeting Subject";
$subject = html_entity_decode($calSubject, ENT_QUOTES, 'UTF-8');
if(mail($calEmail, $calSubject, $message, $headers)) {
echo "sent";
}else {
echo "error";
}
}
It's the DESCRIPTION New \n Line
part i'm having issues with.
Any help will be greatly appreciated
Tom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该将 \r\n 替换为 \n:
另请参阅在 iCal 文件中编码换行符
You should replace \r\n with \n:
See also Encoding newlines in iCal files
您可以使用
=0D=0A
作为具有适当编码的新行:或替代方法(使用 base64):
You can use
=0D=0A
for new line with the appropriate encoding:or an alternative approach (using base64):
在 Windows 上,您可以使用
\r\n
创建新行。更详细地说:
\r
在 ASCII 中是CR
代表“回车”ASCII 中的
\n
是LF
代表“换行”Windows 需要两者的组合,而 Linux 系统只使用
\n
。维基百科的换行符页面。
On Windows you create a new line using
\r\n
.To go into further detail:
\r
in ASCII isCR
standing for "Carriage Return"\n
in ASCII isLF
standing for "Line Feed"Windows requires the combination of both while Linux systems simply use
\n
.There is tons of information (probably more then you'd ever be interested to know) on Wikipedia's Newline page.