Coding on the Outlook calendar

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Coding on the Outlook calendar

Post by Atiq »

On some emails you will notice that your meetings etc are mailed to you as an atttachement on your outlook calendar through which you can see the start time end time etc.

Can we make an email as such that when an email is sent to user we can also send him an attachement file with outlook calendar containing some time information.

Thasnks and Regards,

Atiq
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

You can send an attachment.. i dont know if you can replicate the outlook attach. try sending the attach generate by outlook through php
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Here is a class I wrote to work with my CRM:


Code: Select all

<?php
/*####################################
#THIS CODE WAS CREATED USING JAMES HAWLEY'S PHP CLASS FORM BUILDER xxx

	#November 6, 2004, 6:07 pm
	#FILE NAME
	#makevcsfile.class.php

#Create a VCS file to be used with outlook
 
####################################*/
 
class MakeVCSFileGetOne{
   
   
	var $id;
	var $eventstart; #UNIX TIMESTAMP
	var $eventend; #UNIX TIMESTAMP
	var $summary;
	var $detail;
	var $query_len;
	var $query_str;
	var $location;
   
	function MakeVCSFileGetOne(){
   
	}//END FUNCTION CALL
   	
   	function generateFile(){
   		
		$Filename = "CSCOACT" . $this->getId() . ".vcs";
		header("Content-Type: text/x-vCalendar");
		header("Content-Disposition: inline; filename=$Filename");
		
		/** Put mysql connection and query statements here **/
		
		$DescDump = str_replace("\r", "=0D=0A=", $this->getDetail());
		
		$vCalStart = date("Ymd\THi00", $this->getEventstart());
		$vCalEnd = date("Ymd\THi00", $this->getEventend());
		
		$vSummary = &$this->getSummary();
		$vLocation = &$this->getLocation();
		
		$printF = <<<EOT
BEGIN:VCALENDAR
VERSION:1.0
PRODID:
TZ:-07
BEGIN:VEVENT
SUMMARY:$vSummary \n
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:$DescDump \n
DTSTART:$vCalStart \n
DTEND:$vCalEnd \n
LOCATION;ENCODING=QUOTED-PRINTABLE:$vLocation \n
END:VEVENT
END:VCALENDAR
EOT;

		echo $printF;
		
		
   	}
   	
	function getId(){ return $this->id; }
	function getEventstart(){ return $this->eventstart; }
	function getEventend(){ return $this->eventend; }
	function getSummary(){ return $this->summary; }
	function getDetail(){ return $this->detail; }
	function getQueryLen(){ return $this->query_len; }
	function getQueryStr(){ return $this->query_str; }
	function getLocation(){ return $this->location; }
   
	function setId($x){ $this->id=$x; }
	function setEventstart($x){ $this->eventstart=$x; }
	function setEventend($x){ $this->eventend=$x; }
	function setSummary($x){ $this->summary=$x; }
	function setDetail($x){ $this->detail=$x; }
	function setLocation($x){ $this->location=$x; }
   
	//ASSIGN VAR TO CLASS
	/*
		$MVCSFGO= new MakeVCSFileGetOne();
		$MVCSFGO->setId(123456789);
		$MVCSFGO->setEventstart(20041107060708);
		$MVCSFGO->setEventend(20041108060708);
		$MVCSFGO->setSummary('JAMES TEST MEETING');
		$MVCSFGO->setDetail('BODY ');
		$MVCSFGO->setLocation('LOCATION ');
		$MVCSFGO->generateFile();
	*/
   
}

	

?>
Last edited by hawleyjr on Sun Jan 22, 2006 9:06 am, edited 2 times in total.
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

hawleyjr wrote:Here is a class I wrote to work with my CRM:




$printF = <<<EOT
BEGIN:VCALENDAR
VERSION:1.0
PRODID:
TZ:-07
BEGIN:VEVENT
SUMMARY:$vSummary \n
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:$DescDump \n
DTSTART:$vCalStart \n
DTEND:$vCalEnd \n
LOCATION;ENCODING=QUOTED-PRINTABLE:$vLocation \n
END:VEVENT
END:VCALENDAR
EOT;
echo $printF;
Thanks but if i ran the class with above lines it gives error

Parse error: parse error, unexpected T_CLASS in c:\program files\apache group\apache\htdocs\cms\make_csv.php on line 2


if i removed them then there is no error.

Do i need some thing else for above code to work as i don't much about the above code.

Regards,
Atiq
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

Sorry

Above was some problem of spacing as it is solved now and i can generate vcs files with the above code.

Atiq
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

Atiq, what if you tried this code in place of the part that didn't work?

Code: Select all

$printF = "";
$printF .= "BEGIN:VCALENDAR\n";
$printF .= "VERSION:1.0\n";
$printF .= "PRODID:\n";
$printF .= "TZ:-07\n";
$printF .= "BEGIN:VEVENT\n";
$printF .= "SUMMARY:$vSummary \n\n";
$printF .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:$DescDump \n\n";
$printF .= "DTSTART:$vCalStart \n\n";
$printF .= "DTEND:$vCalEnd \n\n";
$printF .= "LOCATION;ENCODING=QUOTED-PRINTABLE:$vLocation \n\n";
$printF .= "END:VEVENT\n";
$printF .= "END:VCALENDAR";

echo $printF;
Cool library though, by the way the example lines should be in unix timestamp, as the spec says, not in YYYYmmdd etc. format since that example gets me an appointment for 1995 when it looks like you're trying to do November 2004.
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

One mpre thing

how r u generating this value?

20041107060708 which is event start date.
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

That value is the unix timestamp, or number of seconds since 1/1/1970. You could do something like mktime() to get the current time or strtotime("January 1st, 2005 12:00 AM PDT") to get the timestamp for a specific date.
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

Thanks for all the help!

when i am attaching .vcs file and adding some HTML text through the function $MVCSFGO->setDetail('some html message') it is coming in plain text meaning HTML is not taking effect.

If i tried to sent a message like <b>My name is Atiq</b> It is not bolding it instead it is coming with the HTML tags.

Can we sent HTML message in it.

Thanks and Regards,

Atiq
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

2 things typically cause this sort of "problem":
  1. content type mismatch
  2. the chevrons are being converted to their entity forms
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

hawleyjr wrote: $DescDump = str_replace("\r", "=0D=0A=", $this->getDetail());

DESCRIPTION;ENCODING=QUOTED-PRINTABLE:$DescDump \n
Sorry but i didn't understand.

Is there any thing to do with the quoted code to send the HTML instead of plain text.

Atiq
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

No, you can't have any HTML in it.

If you try creating a new appointment in Outlook, it will let you put in formatting... changing the font, setting bold, etc. But if you save the appointment as a VCS file (which is what this is), and open it back up, the formatting is gone.

So you're stuck with plain-text only.
Atiq
Forum Commoner
Posts: 26
Joined: Thu Feb 19, 2004 5:23 am

Post by Atiq »

Thanks it is realy helping a lot

From the above code i can set Start Date,End Date,Time,Subject,Location and Body for .vcs file.

but there are some other parameters as well which i need to set.

for example Reminder,Show time as and Label etc.

Can these be set.

Can u give me the list of what can be set through the coding.

Thanks and Regards,

Atiq
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

When I wrote this code. I got some it from forums and the rest I just created a calendar item in Outlook, saved it to my desktop, opened it in notepad and recreated it....Give that a try and let us know how it works.
Robert Plank
Forum Contributor
Posts: 110
Joined: Sun Dec 26, 2004 9:04 pm
Contact:

Post by Robert Plank »

Hawley when you "wrote" that code, it was mostly stolen from this URL: http://www.phpbuilder.com/columns/chow2 ... int_mode=1

The only thing about that code I don't get is why the "TZ" field was added in, since it does nothing... the time is interpreted as GMT anyway and changing that doesn't change the time zone at least when importing into Outlook.

Atiq, the vCalendar format doesn't let you specify a reminder or label or anything, that's up to the user when they save the appointment in Outlook. You can specify a category e.g. "Business" but that's about the only extra thing.
Post Reply