Outlook会议邀请发送使用PHP无法正常工作

时间:2016-06-02 06:19:06

标签: php codeigniter

我使用ical_library生成会议邀请,并且正在生成代码:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 4.1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:sabre-vobject-4b0105a1-bac5-4068-bd65-b4581d3497c4
DTSTAMP:20160602T081647Z
SUMMARY:Training Schedule Invitation
DTSTART:2016-06-03 09:00:00
DTEND:2016-06-03 10:00:00
LOCATION:Bangalore
ATTENDEE:ragesh@ascent-online.net
END:VEVENT
END:VCALENDAR

但是当我将此代码作为邮件内容发送时,它并未转换为邀请。

显示相同的代码。我使用codeigniter电子邮件库发送电子邮件。

2 个答案:

答案 0 :(得分:0)

当我在线验证ICS数据时,它将返回以下错误:


错误

  

无效的DTSTART值,必须是第5行附近的日期或日期时间值

     

参考:RFC 5545 3.3.5。日期时间

     

无效的DTEND值,必须是第5行附近的日期或日期时间值

     

参考:RFC 5545 3.3.5。日期时间


我的解决方案


我对此也有疑问,最终将ics文件作为附件发送到代码点火器中:

$this->email->attach($ics_data_as_string, 'attachment', $name_for_ics_file_in_email, 'text/calendar');


希望这会有所帮助。

答案 1 :(得分:-1)

private function sendCalEntry( $tsStart, $tsEnd, $location, $summary, $title, $resources, $to, $subject ){

    $from = ORGANISATIONREPLYMAIL;
    $dtstart = date('Ymd',$tsStart).'T'.date('His',$tsStart);
    $dtend = date('Ymd',$tsEnd).'T'.date('His',$tsEnd);
    $loc = $location;

    $vcal = "BEGIN:VCALENDAR\r\n";
    $vcal .= "VERSION:2.0\r\n";
    $vcal .= "PRODID:-//nonstatics.com//OrgCalendarWebTool//EN\r\n";
    $vcal .= "METHOD:REQUEST\r\n";
    $vcal .= "BEGIN:VEVENT\r\n";
    $vcal .= "ORGANIZER;CN=\"".ORGANISATIONNAME." (".$_SESSION['username'].")"."\":mailto:".ORGANISATIONREPLYMAIL."\r\n";
    $vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-nonstatics.com\r\n";
    $vcal .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
    $vcal .= "DTSTART:$dtstart\r\n";
    $vcal .= "DTEND:$dtend\r\n"; 
    $vcal .= "LOCATION:$location\r\n";
    $vcal .= "SUMMARY:$summary\r\n";
    $vcal .= "DESCRIPTION:Hinweis/Fahrer:$summary - Folgende Resourcen wurden gebucht: $resources \r\n";
    $vcal .= "BEGIN:VALARM\r\n";
    $vcal .= "TRIGGER:-PT15M\r\n";
    $vcal .= "ACTION:DISPLAY\r\n";
    $vcal .= "DESCRIPTION:Reminder\r\n";
    $vcal .= "END:VALARM\r\n";
    $vcal .= "END:VEVENT\r\n";
    $vcal .= "END:VCALENDAR\r\n";

    $headers = "From: $from\r\nReply-To: $from"; 
    $headers .= "\r\nMIME-version: 1.0\r\nContent-Type: text/calendar; name=calendar.ics; method=REQUEST; charset=\"iso-8859-1\"";
    $headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 

    return @mail($to, $subject . " " . $summary . " / " . $resources, $vcal, $headers);
}

http://blog.sebastian-martens.de/2012/01/submit-outlook-calendar-invitations-with-php/