我使用以下代码将日历事件发送到Outlook。我遇到时区的问题。我发送开始时间是晚上8点。但是,它设定了第二天的凌晨1点30分。请检查以下代码,并建议我如何随时间发送TimeZones。
<?php
$dtStart = '20131019T131415Z';//yyyymmddThhmmssZ
$dtEnd = '20131019T151617Z';
//--------------------
//create text file
$ourFileName = "temp_files/calendar.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file1");
fclose($ourFileHandle);
//
//edit temp file
$myFile = "temp_files/calendar.txt";
$fh = fopen($myFile, 'w') or die("can't open file2");
$stringData = "
BEGIN:VCALENDAR\n
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN\n
VERSION:2.0\n
METHOD:REQUEST\n
BEGIN:VEVENT\n
ORGANIZER:MAILTO:organizer@domain.com\n
DTSTAMP:".date('Ymd').'T'.date('His')."\n
DTSTART:$dtStart\n
DTEND:$dtEnd\n
TRANSP:OPAQUE\n
SEQUENCE:0\n
UID:".date('Ymd').'T'.date('His')."-".rand()."-domain.com\n
SUMMARY:do something someware\n
DESCRIPTION: This is just a test\n
PRIORITY:5\n
X-MICROSOFT-CDO-IMPORTANCE:1\n
CLASS:PUBLIC\n
END:VEVENT\n
END:VCALENDAR";
fwrite($fh, $stringData);
fclose($fh);
//email temp file
$fileatt = "temp_files/calendar.txt"; // Path to the file
$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = "ical.ics"; // Filename that will be used for the file as the attachment
$email_from = "fromPerson@domain.com"; // Who the email is from
$email_subject = "Email test"; // The Subject of the email
$email_message = "this is a sample message \n\n next line \n\n next line"; // Message that the email has in it
$email_to = "toPerson@domain.com"; // Who the email is too
$headers = "From: ".$email_from;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
&GT?;
答案 0 :(得分:0)
RFC 5545中有很多关于时区的信息。
示例:
DTSTART;TZID=America/New_York:19980119T020000
DTEND;TZID=America/New_York:19980119T030000
TZID=America/New_York:19980119T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
BEGIN:VTIMEZONE
TZID:America/New_York
LAST-MODIFIED:20050809T050000Z
BEGIN:STANDARD
DTSTART:20071104T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
END:DAYLIGHT
END:VTIMEZONE