Page 1 of 2
Coding on the Outlook calendar
Posted: Tue Dec 21, 2004 7:55 am
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
Posted: Tue Dec 21, 2004 12:41 pm
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
Posted: Thu Dec 23, 2004 4:20 pm
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();
*/
}
?>
Posted: Mon Dec 27, 2004 3:51 am
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
Posted: Mon Dec 27, 2004 5:36 am
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
Posted: Mon Dec 27, 2004 5:42 am
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.
Posted: Mon Dec 27, 2004 8:28 am
by Atiq
One mpre thing
how r u generating this value?
20041107060708 which is event start date.
Posted: Mon Dec 27, 2004 9:39 am
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.
Posted: Tue Dec 28, 2004 9:55 am
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
Posted: Tue Dec 28, 2004 11:25 am
by feyd
2 things typically cause this sort of "problem":
- content type mismatch
- the chevrons are being converted to their entity forms
Posted: Wed Dec 29, 2004 2:07 am
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
Posted: Wed Dec 29, 2004 9:05 am
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.
Posted: Thu Dec 30, 2004 12:51 am
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
Posted: Thu Dec 30, 2004 7:18 am
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.
Posted: Thu Dec 30, 2004 9:12 am
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.