PHP在一个电子邮件中向Outlook发送多个事件请求 [英] PHP send multiple event requests in one email to Outlook

查看:513
本文介绍了PHP在一个电子邮件中向Outlook发送多个事件请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过下面的代码&能够将一个嵌入的ics中的多个事件发送到Google日历。但是如果我在MS Outlook 2010中只打开同一封邮件第一个日期会显示在Outlook日历中。

I have tried below code & was able to send multiple events in one embedded ics to google calendar. But if I open the same mail in MS Outlook 2010 only the first date is displayed in the outlook calendar.

以下是我的代码。 / p>

Below is my code.

<?php 
$ical4 = 'BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20150310T183001Z
DTEND:20150310T182959Z
DTSTAMP:20150310T183000Z
UID:2015-03-10_leave_24@gmail.com
ORGANIZER:MAILTO:organizer@gmail.com
ATTENDEE:MAILTO:testuser1@gmail.com
DESCRIPTION:Test E1 Desc
STATUS:CONFIRMED
SEQUENCE:0
SUMMARY:Test E1
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20150311T183001Z
DTEND:20150311T182959Z
DTSTAMP:20150310T183000Z
UID:2015-03-11_leave_25@gmail.com
ORGANIZER:MAILTO:organizer@gmail.com
ATTENDEE:MAILTO:testuser1@gmail.com
DESCRIPTION:Test E2 Desc
STATUS:CONFIRMED
SEQUENCE:0
SUMMARY:Test E2
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR';


$from_name = "My Name";
    $from_address = "myname@mydomain.com";
    $subject = "Test Events_1";

//Create Mime Boundry
    $mime_boundary = "----Meeting Booking----".md5(time());

    //Create Email Headers
    $headers = "From: ".$from_name." <".$from_address.">\n";
    $headers .= "Reply-To: ".$from_name." <".$from_address.">\n";

    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
    $headers .= "Content-class: urn:content-classes:calendarmessage\n";

    //Create Email Body (HTML)
    $message = "";
    $message .= "--$mime_boundary\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";

    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= '<p>Dear user,</p>';
    $message .= '<p>Here is my HTML Email / Used for Meeting Description</p>';    
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--$mime_boundary\n";

$message .= 'Content-Type: text/calendar; name="meeting.ics";method=REQUEST; charset=utf-8\n';
$message .= 'Content-Disposition: inline;\n';
    $message .= "Content-Transfer-Encoding: 2048bit\n\n";
    $message .= $ical4; 

    //SEND MAIL
    $mail_sent = @mail( $email, $subject, $message, $headers );

    if($mail_sent)     {
        return true;
    } else {
        return false;
    }   

请注意,如果我将内容复制到.ics文件,导入到MS Outlook 2010,它成功更新两个事件。但是,我需要通过使用php发送邮件自动更新Outlook的日历。

Note that if I copy the ical content to a .ics file & import to MS Outlook 2010, it gets updated successfully with two events. But, I need to update the outlook calendar automatically by sending a mail using php.

有没有什么方式如何发送多个事件在一个电子邮件到MS Outlook 2010所以它会自动添加到Outlook日历?

Is there any way how we can send multiple events in one email to MS Outlook 2010 so that it will be automatically added to Outlook calendar?

推荐答案

基本上,这不工作。 iMip消息往往只有1个事件。

Basically, this doesn't work. iMip messages tend to only have 1 event.

但是,解决这个问题的一种方法是将其转换为具有两个实例的重复事件。

However, one way to work around it, is to turn this into a recurring event with two instances.

要做到这一点,你需要确保 UID 对于这两个消息是相同的,并且其中一个消息有 RECURRENCE-ID 。初始(主事件)将需要 RDATE RRULE 使事件重复,第二个事件将作为一个被覆盖的实例。

To do that, you'll need to make sure that UID is identical for both messages, and one of the messages has a RECURRENCE-ID. The initial (master event) will need to have either RDATE or RRULE to make the event recurring, and the second event will act as an overridden instance.

我不知道 RDATE 如何在每个客户端工作,不知道Outlook 2010是否支持它。我知道 RRULE 被广泛支持。

I don't know how well RDATE works on every client, and I don't know if Outlook 2010 supports it. I do know RRULE is widely supported though.

这篇关于PHP在一个电子邮件中向Outlook发送多个事件请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆