0

Hi all,
my boss want me to send an calendar invitation event to Microsoft Outlook
i have tried many time already and it still give me the result
"This is no a valid internet calendar file"

and here my code:

$vcal = "BEGIN:VCALENDAR";
  $vcal .= "VERSION:2.0";
  $vcal .= "PRODID:-//CompanyName//ProductName//EN";
  $vcal .= "METHOD:REQUEST";
  $vcal .= "BEGIN:VEVENT";
  $vcal .= "ATTENDEE;CN=\"Attendee1Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att1Mail@mail.com";
  $vcal .= "ATTENDEE;CN=\"Attendee2Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att2Mail@mail.com";
  $vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-example.com.my";
  $vcal .= "DTSTAMP:".date('Ymd').'T'.date('His');
  $vcal .= "DTSTART:09/06/2011";
  $vcal .= "DTEND:10/06/2011"; 
  $vcal .= "LOCATION:Meeting room 2";
  $vcal .= "SUMMARY:hahaha....meeting";
  $vcal .= "BEGIN:VALARM";
  $vcal .= "TRIGGER:-PT15M";
  $vcal .= "ACTION:DISPLAY";
  $vcal .= "DESCRIPTION:Reminder";
  $vcal .= "END:VALARM";
  $vcal .= "END:VEVENT";
  $vcal .= "END:VCALENDAR";
 

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

 	//Create the Transport
	$transport = Swift_SmtpTransport::newInstance('mail.example.com.my',25)
      ->setUsername('php.mailer@example.com.my')
      ->setPassword('abc123456');
	
	//Create the Mailer using your created Transport
	$mailer = Swift_Mailer::newInstance($transport);
	
		//Create a message
	$message = Swift_Message::newInstance('Meeting Invite Testing')
	 
	 ->setFrom(array('php.mailer@example.com.my'))
	 ->setTo(array('example@example.com.my')) 
	 //->setTo($to_mail) 
	 //->setCc($cc_mail)
	 //->setBcc($bcc_mail)
	 ->addPart($vcal,'text/calendar');
	//Send the message
    $result = $mailer->send($message);

you can see from here i'm using swift mailer! any one know how to solve my problem?
i'm appreciate for any help!

PS: the email will be send out with an calendar invitation as attachment.
and my problem is i can't open the attachment! God!

Edited by Nybuler: n/a

3
Contributors
9
Replies
14
Views
6 Years
Discussion Span
Last Post by Foo_1
0

Just try the following code and check wheather the calendar opens correctly or not.

header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");

$vcal = "BEGIN:VCALENDAR";
$vcal .= "VERSION:2.0";
$vcal .= "PRODID:-//CompanyName//ProductName//EN";
$vcal .= "METHOD:REQUEST";
$vcal .= "BEGIN:VEVENT";
$vcal .= "ATTENDEE;CN=\"Attendee1Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att1Mail@mail.com";
$vcal .= "ATTENDEE;CN=\"Attendee2Name\";ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:Att2Mail@mail.com";
$vcal .= "UID:".date('Ymd').'T'.date('His')."-".rand()."-besta.com.my";
$vcal .= "DTSTAMP:".date('Ymd').'T'.date('His');
$vcal .= "DTSTART:09/06/2011";
$vcal .= "DTEND:10/06/2011";
$vcal .= "LOCATION:Meeting room 2";
$vcal .= "SUMMARY:hahaha....meeting";
$vcal .= "BEGIN:VALARM";
$vcal .= "TRIGGER:-PT15M";
$vcal .= "ACTION:DISPLAY";
$vcal .= "DESCRIPTION:Reminder";
$vcal .= "END:VALARM";
$vcal .= "END:VEVENT";
$vcal .= "END:VCALENDAR";

echo $val;

exit;

Edited by karthik_ppts: missing something

0

thank for help
but where should i place your code?
you mean i don't send the email but echo it out to see the result 1st?

0

for the header i gain this error

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\eform\accomodation\haha.php:2) in C:\xampp\htdocs\eform\accomodation\haha.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\eform\accomodation\haha.php:2) in C:\xampp\htdocs\eform\accomodation\haha.php on line 6


what does it mean?

do you have suggest link for how to write vcalendar?

0

Your calendar is not opening. Try ur code with this script.

echo "BEGIN:VCALENDAR\n";
	echo "VERSION:2.0\n";
	echo "PRODID://Foobar Corporation//NONSGML Foobar//EN\n";
	echo "METHOD:PUBLISH\n"; // requied by Outlook
	echo "X-WR-CALNAME:PH2011\n";
	echo "X-WR-TIMEZONE:Asia/Singapore\n";
	echo "BEGIN:VEVENT\n";
	echo "UID:".date('Ymd').'T'.date('His')."-".rand()."-example.com\n"; // required by Outlok
	echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook
	echo "DTSTART:Your Date\n"; 
	echo "SUMMARY:Your Summary Here\n";
	echo "LOCATION: Your Location Here\n";
	echo "DESCRIPTION: Your Description Here\n";
	echo "END:VEVENT\n";
	echo "END:VCALENDAR\n";

Edited by karthik_ppts: n/a

0

Hey, I'm thankful for your coding ! It work for the first time
that i have tried 100 times testing T^T thank you!

One more question:

Does it work in Thunderbird?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.