Sending vCalendar message from PHP
Moderator: General Moderators
Sending vCalendar message from PHP
Hi,
How can I send a vCalendar message from PHP so that Microsoft Outlook receives it as an appointment. I have tried using the mail() function and setting the headers as per vCalendar but I am receiving it as a normal mail rather than an appointment. Can someone look at my code and help me
- Teli
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
$eol="\r";
} else {
$eol="\n";
}
$headers .= 'From: Myself <myself@gmail.com>'.$eol ;
$headers .= 'Subject: Trying' . $eol;
$headers .= 'To: You <you@yourdomain.com>' .$eol ;
$headers .= 'Mime-Version: 1.0' .$eol;
# $headers .= "Content-Type: multipart/mixed; boundary=vCalendar" .$eol;
$headers .= 'Content-Type: multipart/mixed; boundary="vCalendar"' .$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= '--vCalendar' .$eol;
$headers .= 'Content-Type: text/plain; charset=us-ascii' .$eol;
$headers .= 'Content-Transfer-Encoding: 7bit' .$eol;
$headers .= '--vCalendar' .$eol;
$headers .= "BEGIN:VCALENDAR".$eol;
$headers .= "VERSION:1.0".$eol;
$headers .= "BEGIN:VEVENT".$eol;
$headers .= "CATEGORIES:MEETING".$eol;
$headers .= "STATUS:TENTATIVE".$eol;
$headers .= "DTSTART:20090401T033000Z".$eol;
$headers .= "DTEND:20090401T043000Z".$eol;
$headers .= "SUMMARY:Your Proposal Review".$eol;
$headers .= "DESCRIPTION:Steve and John to review newest proposal material".$eol;
$headers .= "CLASS:PRIVATE".$eol;
$headers .= "END:VEVENT".$eol;
$headers .= "END:VCALENDAR".$eol;
$headers .= '--vCalendar' .$eol;
$headers .= 'Text/X-vCalendar Content Type' .$eol;
$msg = "" .$eol;
$msg .= "How are you " .$eol;
ini_set(sendmail_from,$fromaddress);
mail($emailaddress, $emailsubject, $msg, $headers);
How can I send a vCalendar message from PHP so that Microsoft Outlook receives it as an appointment. I have tried using the mail() function and setting the headers as per vCalendar but I am receiving it as a normal mail rather than an appointment. Can someone look at my code and help me
- Teli
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
$eol="\r";
} else {
$eol="\n";
}
$headers .= 'From: Myself <myself@gmail.com>'.$eol ;
$headers .= 'Subject: Trying' . $eol;
$headers .= 'To: You <you@yourdomain.com>' .$eol ;
$headers .= 'Mime-Version: 1.0' .$eol;
# $headers .= "Content-Type: multipart/mixed; boundary=vCalendar" .$eol;
$headers .= 'Content-Type: multipart/mixed; boundary="vCalendar"' .$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= '--vCalendar' .$eol;
$headers .= 'Content-Type: text/plain; charset=us-ascii' .$eol;
$headers .= 'Content-Transfer-Encoding: 7bit' .$eol;
$headers .= '--vCalendar' .$eol;
$headers .= "BEGIN:VCALENDAR".$eol;
$headers .= "VERSION:1.0".$eol;
$headers .= "BEGIN:VEVENT".$eol;
$headers .= "CATEGORIES:MEETING".$eol;
$headers .= "STATUS:TENTATIVE".$eol;
$headers .= "DTSTART:20090401T033000Z".$eol;
$headers .= "DTEND:20090401T043000Z".$eol;
$headers .= "SUMMARY:Your Proposal Review".$eol;
$headers .= "DESCRIPTION:Steve and John to review newest proposal material".$eol;
$headers .= "CLASS:PRIVATE".$eol;
$headers .= "END:VEVENT".$eol;
$headers .= "END:VCALENDAR".$eol;
$headers .= '--vCalendar' .$eol;
$headers .= 'Text/X-vCalendar Content Type' .$eol;
$msg = "" .$eol;
$msg .= "How are you " .$eol;
ini_set(sendmail_from,$fromaddress);
mail($emailaddress, $emailsubject, $msg, $headers);
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Sending vCalendar message from PHP
Have a look at http://www.ietf.org/rfc/rfc2447.txt
Looks like your content-type isn't right.
This is one way if the vcal is in the body...
Content-Type:text/calendar; method=REQUEST; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Would allow the vcal data to be in the body from what I can see.
You can also do it as a multipart with plain text version in the body and vcal data in the header - but the standard has different headers to yours for content-type again.
I had a game with vcal implementation a while back because Outlook isn't standards compliant!!! I just had it as a download rather than an email. I can post the code if it would help
Looks like your content-type isn't right.
This is one way if the vcal is in the body...
Content-Type:text/calendar; method=REQUEST; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Would allow the vcal data to be in the body from what I can see.
You can also do it as a multipart with plain text version in the body and vcal data in the header - but the standard has different headers to yours for content-type again.
Code: Select all
$headers .= 'From: Myself <myself@gmail.com>'.$eol ;
$headers .= 'Subject: Trying' . $eol;
$headers .= 'To: You <you@yourdomain.com>' .$eol ;
$headers .= 'Mime-Version: 1.0' .$eol;
$headers .= 'Content-Type:text/calendar; method=REQUEST; charset=US-ASCII '.$eol;- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Sending vCalendar message from PHP
Just had a go...
Worked nicely - the message arrived as an appointment, double clicking it allowed it to be saved, but it went to the Junk folder!
Code: Select all
<?php
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\r\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
$eol="\r";
} else {
$eol="\n";
}
$headers .= 'From: Myself <***>'.$eol ;
$headers .= 'Subject: Trying' . $eol;
$headers .= 'Mime-Version: 1.0' .$eol;
$headers .= 'Content-Type:text/calendar; method=REQUEST; charset=US-ASCII';
$headers .= 'Content-Transfer-Encoding: 7bit';
$message = "BEGIN:VCALENDAR".$eol;
$message .= "VERSION:1.0".$eol;
$message .= "BEGIN:VEVENT".$eol;
$message .= "CATEGORIES:MEETING".$eol;
$message .= "STATUS:TENTATIVE".$eol;
$message.= "DTSTART:20090401T033000Z".$eol;
$message .= "DTEND:20090401T043000Z".$eol;
$message .= "SUMMARY:Your Proposal Review".$eol;
$message .= "DESCRIPTION:Steve and John to review newest proposal material".$eol;
$message .= "CLASS:PRIVATE".$eol;
$message .= "END:VEVENT".$eol;
$message .= "END:VCALENDAR".$eol;
//ini_set(sendmail_from,$fromaddress);
mail($emailaddress, 'Appointment', $message, $headers);
?>
Re: Sending vCalendar message from PHP
Good Morning,
Your code andym01480 don't work when I test it. It send me an email, but without an appointment
here is my code :
it's exactly the same code that andym01480 posted right above and I just changed 2 things. My email and a line 'PRODID ...'.
Can somebody help me and tell me why it doesn't work ? By the way did the posted code helped you teli35 ? Or somebody else ?
Thanx a lot, and sorry for my english, actually I'm french.
Bye.
Your code andym01480 don't work when I test it. It send me an email, but without an appointment
here is my code :
Code: Select all
<?php
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
$eol="\n";
} elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) {
$eol="\r";
} else {
$eol="\n";
}
$headers = 'From: $mail'.$eol ;
$headers .= 'Subject: Trying' . $eol;
$headers .= 'Mime-Version:1.0' .$eol;
$headers .= 'Content-Type: text/calendar; method=REQUEST; charset=iso-8859-1'.$eol;
$headers .= 'Content-Transfer-Encoding: 8bit'.$eol;
$message = "BEGIN:VCALENDAR".$eol;
$message .="PRODID:-//Microsoft Corporation//Outlook 9.0 MIMEDIR//EN".$eol;
$message .= "VERSION:1.0".$eol;
$message .= "BEGIN:VEVENT".$eol;
$message .= "CATEGORIES:MEETING".$eol;
$message .= "STATUS:TENTATIVE".$eol;
$message .= "DTSTART:20090401T033000Z".$eol;
$message .= "DTEND:20090401T043000Z".$eol;
$message .= "SUMMARY:Your Proposal Review".$eol;
$message .= "DESCRIPTION:Steve and John to review newest proposal material".$eol;
$message .= "CLASS:PRIVATE".$eol;
$message .= "END:VEVENT".$eol;
$message .= "END:VCALENDAR".$eol;
//ini_set(sendmail_from,$fromaddress);
mail('$mail', 'Appointment', $message, $headers);
?>Can somebody help me and tell me why it doesn't work ? By the way did the posted code helped you teli35 ? Or somebody else ?
Thanx a lot, and sorry for my english, actually I'm french.
Bye.
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Sending vCalendar message from PHP
Bonjour!
Did you try my code as is with only the email changed? I have no idea what the PRODID line does! Maybe that caused the failure. The code I posted worked with Outlook 2002!
Did you try my code as is with only the email changed? I have no idea what the PRODID line does! Maybe that caused the failure. The code I posted worked with Outlook 2002!
Re: Sending vCalendar message from PHP
Yes I tried but it doesn't work too. It send me a simple email. Do you have any other idea ?
Oh I work with Outlook 2000. What do I have to change to make this code work with Outlook 2000 ?
Oh I work with Outlook 2000. What do I have to change to make this code work with Outlook 2000 ?
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: Sending vCalendar message from PHP
I think you will have to google vcal and "outlook 2000" as Microsoft's upport for vcal is a little patchy
Re: Sending vCalendar message from PHP
ok so you don't know, I have to look for it on google.
Ok thx for your answers ! If you have information please post them on forum.
Bye.
Ok thx for your answers ! If you have information please post them on forum.
Bye.
Re: Sending vCalendar message from PHP
Hello,
did the code that you posted works with Outlook 2003 ?
thx
did the code that you posted works with Outlook 2003 ?
thx