0

诡异的。在 Web 和 Outlook 中,它显示为我可以添加到日历中的约会;但在手机上的 Gmail 应用程序中,它显示为普通电子邮件(无法添加到日历)。这是我的功能:

function mail_agenda($dtstart,$dtend,$loc,$summary,$from,$to,$subject) {
  $vcal = "BEGIN:VCALENDAR\r\n";
  $vcal .= "VERSION:2.0\r\n";
  $vcal .= "PRODID:-//CompanyName//ProductName//EN\r\n";
  $vcal .= "METHOD:REQUEST\r\n";
  $vcal .= "BEGIN:VEVENT\r\n";
  // $vcal .= "ATTENDEE;CN=\"Attendee1Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att1Mail@mail.com\r\n";
  // $vcal .= "ATTENDEE;CN=\"Attendee2Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att2Mail@mail.com\r\n";
  $vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-domain.com\r\n";
  $vcal .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";

  $vcal .= "ORGANIZER;CN=Sistema:MAILTO:john.doe@example.com\r\n";

  $vcal .= "DTSTART:$dtstart\r\n";
  $vcal .= "DTEND:$dtend\r\n"; 
  if ($loc != "") $vcal .= "LOCATION:$loc\r\n";
  $vcal .= "SUMMARY:$summary\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; method=REQUEST; charset=\"iso-8859-1\"";
  $headers .= "\r\nContent-Transfer-Encoding: 7bit\r\nX-Mailer: Microsoft Office Outlook 12.0"; 

  mail($to, $subject, $vcal, $headers);
 }
4

0 回答 0