RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-14 Thread Richard Lynch
On Mon, June 13, 2005 6:36 pm, [EMAIL PROTECTED] said:
 Hi, perhaps someone might be able to look at this code - it works when I
 run it from the command line, but not when viewed through a web page. I
 am running IIS 6 on Windows 2003 server.

The most likely problem is either:

Permisssions -- God only knows what the W2K3 user/permissions model is.
They changed it every version, and nobody understands it in the first
place. But whatever it is, your IIS runs_as a specific user, probably,
which PHP inherits, and that user just doesn't have permission to do what
you do on the command line.

Paths -- When you are on a command line, be it MS-DOS or CygWin or
whatever, you have specific $PATH (and/or $path) environment variables
set.  Your PHP user almost-for-sure has different $PATH settings.  Use
full pathnames for EVERYTHING.  Binaries, data files, everything.

Far less likely, but possible, if you've checked the above:

Are the PHP and MySQL versions the same in both your command line and
web-server installations?

Maybe find one of the 10 guys who actually understands W2K3
user/permissions system first.  That's not me. :-^

Oh, and finally...

You may want to consider just abandoning this Outlook crap and using
http://php.net/imap to manipulate the emails.  Won't help you with the
calendar stuff, though, I don't think, unless you can figure out that it's
all done with custom X-headers or something.

 Thanks
 Justin


 ?php
 $comobjOutlook = new COM(outlook.application) or die(Unable to
 instantiate outlook);


 $comobjOutlook - Activate;


 # This is your mailbox name just like it appears in your Folders view.
 It might be 'Inbox' or something else.
 $targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);


 # This is the folder you're looking for. In this case, I'm looking for
 calendar items, but you can look for
 # any folder. You need to add another loop to look for subfolders.
 Although there's probably a better
 # way, that's how I did it when I needed to get to Personal
 Folders/Inbox/Subfoldername
 $targetfoldername = Calendar;


 $objNamespace = $comobjOutlook-GetNameSpace(MAPI);
 $objFolders = $objNamespace-Folders();
 $mailboxcount = $objFolders - Count();


 $foundmailbox = FALSE;
 for ($i=1; $i=$mailboxcount; $i++) {
   $folderitem = $objFolders -Item($i);
   if ($folderitem - Name == $targetmailboxname) {
 $objMailbox = $folderitem;
 $foundmailbox = TRUE;
   }
 }


 $foundcal = FALSE;
 if ($foundmailbox) {
   $objFolders = $objMailbox-Folders();
   $foldercount = $objFolders - Count();


   for ($i=1; $i=$foldercount; $i++) {
 $folderitem = $objFolders - Item($i);
 if ($folderitem - Name == $targetfoldername) {
   $objCalendar = $folderitem;
   $foundcal = TRUE;
 }
   }


   if ($foundcal) {
 $objItems = $objCalendar-Items();
 $itemcount = $objItems-Count();


 for ($i=1; $i=$itemcount; $i++) {
   $apptitem = $objItems - Item($i);
   $apptstart = $apptitem - Start();
   $apptend = $apptitem - End();
   $apptallday = $apptitem - AllDayEvent();
   $apptrecur = $apptitem - IsRecurring();
   $apptsubject = $apptitem - Subject();
   $apptlocation = $apptitem - Location();


   $secondsadj = $apptstart - 14400;
   $startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));



   $secondsadj = $apptend - 14400;
   $endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));


   if($apptallday) { $allday = All Day; } else { $allday = ; }
   if($apptrecur) { $recurring = Recurring; } else { $recurring ; }


   echo $apptsubject @ $apptlocation\r\nFrom: $startadj To:
 $endadj\r\n;
   if ($allday   OR $recurring  ) echo $allday
 $recurring\r\n;
   echo \r\n\r\n;
 }


   } else {
 die (Did not find calendar folder);
   }


 } else {
   die(Did not find target mailbox: $targetmailboxname);
 }
 ?

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-13 Thread Justin.Baiocchi
Hi, perhaps someone might be able to look at this code - it works when I
run it from the command line, but not when viewed through a web page. I
am running IIS 6 on Windows 2003 server.

Thanks
Justin


?php 
$comobjOutlook = new COM(outlook.application) or die(Unable to
instantiate outlook);
 

$comobjOutlook - Activate;
 

# This is your mailbox name just like it appears in your Folders view.
It might be 'Inbox' or something else. 
$targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);
 

# This is the folder you're looking for. In this case, I'm looking for
calendar items, but you can look for 
# any folder. You need to add another loop to look for subfolders.
Although there's probably a better 
# way, that's how I did it when I needed to get to Personal
Folders/Inbox/Subfoldername 
$targetfoldername = Calendar; 
 

$objNamespace = $comobjOutlook-GetNameSpace(MAPI); 
$objFolders = $objNamespace-Folders(); 
$mailboxcount = $objFolders - Count(); 
 

$foundmailbox = FALSE; 
for ($i=1; $i=$mailboxcount; $i++) { 
  $folderitem = $objFolders -Item($i); 
  if ($folderitem - Name == $targetmailboxname) { 
$objMailbox = $folderitem; 
$foundmailbox = TRUE; 
  } 
} 
 

$foundcal = FALSE; 
if ($foundmailbox) { 
  $objFolders = $objMailbox-Folders(); 
  $foldercount = $objFolders - Count(); 
 

  for ($i=1; $i=$foldercount; $i++) { 
$folderitem = $objFolders - Item($i); 
if ($folderitem - Name == $targetfoldername) { 
  $objCalendar = $folderitem; 
  $foundcal = TRUE; 
} 
  } 
 

  if ($foundcal) { 
$objItems = $objCalendar-Items(); 
$itemcount = $objItems-Count(); 
 

for ($i=1; $i=$itemcount; $i++) { 
  $apptitem = $objItems - Item($i); 
  $apptstart = $apptitem - Start(); 
  $apptend = $apptitem - End(); 
  $apptallday = $apptitem - AllDayEvent(); 
  $apptrecur = $apptitem - IsRecurring(); 
  $apptsubject = $apptitem - Subject(); 
  $apptlocation = $apptitem - Location(); 
 

  $secondsadj = $apptstart - 14400; 
  $startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));

 

  $secondsadj = $apptend - 14400; 
  $endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970)); 
 

  if($apptallday) { $allday = All Day; } else { $allday = ; } 
  if($apptrecur) { $recurring = Recurring; } else { $recurring =
; } 
 

  echo $apptsubject @ $apptlocation\r\nFrom: $startadj To:
$endadj\r\n; 
  if ($allday   OR $recurring  ) echo $allday
$recurring\r\n; 
  echo \r\n\r\n; 
} 
 

  } else { 
die (Did not find calendar folder); 
  } 
 

} else { 
  die(Did not find target mailbox: $targetmailboxname); 
} 
? 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-07 Thread tg-php
Sorry, wasn't able to test this when I got home.  But to clearify, when you use 
COM, it's loading Outlook (as you've seen) and then talking directly to it.  So 
you don't need an exchange server to make it work.

Try tracing through the code and see where it's failing.  And nothing's showing 
up when you do View source (I know you said it's continuously running but 
curious what happens if you stop the page load and see what's been output)?   
Have you tried running the script via command line?

I'd be curious to see how far the script gets for you before it bombs out.   It 
might be trying to tell Outlook to do something and just hanging (hence the 
perpetual loading in your browser) which is why I'm wondering how far it gets 
and what happens if you run it via command-line.

More info would definitely be appreciated.

-TG

= = = Original message = = =

Still no luck I am afraid. Same thing happens - it kicks off an instance
of Outlook.exe on the server, but the page never loads, it just stays
blank with a never-ending progress bar.

I thought it could be security related but have shared out my Calendar
with default having reviewer access.

I am using an Exchange server but don't want to follow the route of
sharing Calendars and accessing them in Outlook. 

Is the problem with the script that it has to access an Exchange server
to read the Calendar, even while Outlook is installed on the server and
configured with the same profile?

Thanks
Justin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 7 June 2005 1:01 AM
To: php-general@lists.php.net
Cc: Baiocchi, Justin (CSIRO IT, Armidale)
Subject: Re: [PHP] Displaying an Outlook Calendar on a webpage using PHP


That looks like some of my code.. or a derivative of my code.   For some
reason, my PC at work here is having issues with PHP instantiating with
COM so I can't test this, but the code you posted is conspicuously
missing all the braces  .  I'm guessing that's not your issue
though... or else you'd be getting some kind of error maybe.

Anyway, here's a re-braced version of the code.   It should produce
something when run through a web browser, but you might View Source and
see what shows up there.

This does require Outlook to be installed on the PC that PHP is running
on, as that's how COM works.   I never messed around with remote COM
calls, but I'm sure there's some way to do that.

If someone wants to try this code and see if there are other issues
besides the missing braces.  I don't see anything obviously wrong with
it (besides maybe some sloppy programming on my part :).  I'll see about
checking it when I get home tonight if I have time.

?php
$comobjOutlook = new COM(outlook.application) or die(Outlook not
loaded);

//$comobjOutlook - Activate;

# This is your mailbox name just like it appears in your Folders view.
# It might be 'Inbox' or something else.
$targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);


# This is the folder you're looking for. In this case, I'm looking for
calendar
# items, but you can look for any folder. You need to add another loop
to look
# for subfolders. Although there's probably a better way, that's how I
did it when 
# I needed to get to Personal Folders/Inbox/Subfoldername
$targetfoldername = Calendar;

$objNamespace = $comobjOutlook-GetNameSpace(MAPI);
$objFolders = $objNamespace-Folders();
$mailboxcount = $objFolders - Count();


$foundmailbox = FALSE;
for ($i=1; $i=$mailboxcount; $i++) 
  $folderitem = $objFolders -Item($i);
  if ($folderitem - Name == $targetmailboxname) 
$objMailbox = $folderitem;
$foundmailbox = TRUE;

$foundcal = FALSE;
if ($foundmailbox) 
  $objFolders = $objMailbox-Folders();
  $foldercount = $objFolders - Count();

  for ($i=1; $i=$foldercount; $i++) 
$folderitem = $objFolders - Item($i);
if ($folderitem - Name == $targetfoldername) 
  $objCalendar = $folderitem;
  $foundcal = TRUE;

  



if ($foundcal) 
  $objItems = $objCalendar-Items();
  $itemcount = $objItems-Count();

  for ($i=1; $i=$itemcount; $i++) 
$apptitem = $objItems - Item($i);
$apptstart = $apptitem - Start();
$apptend = $apptitem - End();
$apptallday = $apptitem - AllDayEvent();
$apptrecur = $apptitem - IsRecurring();
$apptsubject = $apptitem - Subject();
$apptlocation = $apptitem - Location();

$secondsadj = $apptstart - 14400;
$startadj = date(m/d/Y H:i:s,
mktime(0,0,$secondsadj,1,1,1970));

$secondsadj = $apptend - 14400;
$endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));

if($apptallday)  $allday = All Day;  else  $allday = ;
if($apptrecur)  $recurring = Recurring;  else  $recurring =
;

echo $apptsubject @ $apptlocation\r\nFrom: $startadj To:
$endadj\r\n;

if ($allday   OR $recurring  ) echo $allday
$recurring\r\n;
echo \r\n

RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-07 Thread Justin.Baiocchi
To be honest I am not sure where the code is failing - it is starting
Outlook.exe on the server so I assume it is able to instantiate the COM
application (I think that is what it is called!).

If I stop the page load and do a 'view source' all I see is
html/html and nothing else. The Outlook.exe process also remains
running on the server and has to be killed with Task Manager.

However, when run from the command line the script WORKS!!! What can
that mean?


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 8 June 2005 12:33 AM
To: php-general@lists.php.net
Cc: Baiocchi, Justin (CSIRO IT, Armidale)
Subject: RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP


Sorry, wasn't able to test this when I got home.  But to clearify, when
you use COM, it's loading Outlook (as you've seen) and then talking
directly to it.  So you don't need an exchange server to make it work.

Try tracing through the code and see where it's failing.  And nothing's
showing up when you do View source (I know you said it's continuously
running but curious what happens if you stop the page load and see
what's been output)?   Have you tried running the script via command
line?

I'd be curious to see how far the script gets for you before it bombs
out.   It might be trying to tell Outlook to do something and just
hanging (hence the perpetual loading in your browser) which is why I'm
wondering how far it gets and what happens if you run it via
command-line.

More info would definitely be appreciated.

-TG

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-06 Thread tg-php
That looks like some of my code.. or a derivative of my code.   For some 
reason, my PC at work here is having issues with PHP instantiating with COM so 
I can't test this, but the code you posted is conspicuously missing all the 
braces { }.  I'm guessing that's not your issue though... or else you'd be 
getting some kind of error maybe.

Anyway, here's a re-braced version of the code.   It should produce something 
when run through a web browser, but you might View Source and see what shows up 
there.

This does require Outlook to be installed on the PC that PHP is running on, as 
that's how COM works.   I never messed around with remote COM calls, but I'm 
sure there's some way to do that.

If someone wants to try this code and see if there are other issues besides the 
missing braces.  I don't see anything obviously wrong with it (besides maybe 
some sloppy programming on my part :).  I'll see about checking it when I get 
home tonight if I have time.

?php
$comobjOutlook = new COM(outlook.application) or die(Outlook not loaded);

//$comobjOutlook - Activate;

# This is your mailbox name just like it appears in your Folders view.
# It might be 'Inbox' or something else.
$targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);


# This is the folder you're looking for. In this case, I'm looking for calendar
# items, but you can look for any folder. You need to add another loop to look
# for subfolders. Although there's probably a better way, that's how I did it 
when 
# I needed to get to Personal Folders/Inbox/Subfoldername
$targetfoldername = Calendar;

$objNamespace = $comobjOutlook-GetNameSpace(MAPI);
$objFolders = $objNamespace-Folders();
$mailboxcount = $objFolders - Count();


$foundmailbox = FALSE;
for ($i=1; $i=$mailboxcount; $i++) {
  $folderitem = $objFolders -Item($i);
  if ($folderitem - Name == $targetmailboxname) {
$objMailbox = $folderitem;
$foundmailbox = TRUE;

$foundcal = FALSE;
if ($foundmailbox) {
  $objFolders = $objMailbox-Folders();
  $foldercount = $objFolders - Count();

  for ($i=1; $i=$foldercount; $i++) {
$folderitem = $objFolders - Item($i);
if ($folderitem - Name == $targetfoldername) {
  $objCalendar = $folderitem;
  $foundcal = TRUE;
}
  }
}


if ($foundcal) {
  $objItems = $objCalendar-Items();
  $itemcount = $objItems-Count();

  for ($i=1; $i=$itemcount; $i++) {
$apptitem = $objItems - Item($i);
$apptstart = $apptitem - Start();
$apptend = $apptitem - End();
$apptallday = $apptitem - AllDayEvent();
$apptrecur = $apptitem - IsRecurring();
$apptsubject = $apptitem - Subject();
$apptlocation = $apptitem - Location();

$secondsadj = $apptstart - 14400;
$startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));

$secondsadj = $apptend - 14400;
$endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));

if($apptallday)  $allday = All Day;  else  $allday = ;
if($apptrecur)  $recurring = Recurring;  else  $recurring = ;

echo $apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n;

if ($allday   OR $recurring  ) echo $allday $recurring\r\n;
echo \r\n\r\n;
  }
} else {
  die (Did not find calendar folder);
}
  } else {
die(Did not find target mailbox: $targetmailboxname);
  }
}
?



= = = Original message = = =

Hello all,
 
I am trying to publish an Outlook Calendar on a web page using PHP and
COM. I have managed to track down on the net some examples of how it
could be done. The most promising is the code below. However, all that
happens is that outlook.exe is started on the server, but nothing is
displayed on the web page and it just times-out.
 
I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
installed on the server.
Does anybody know why it doesn't work?
 
Thanks 
Justin


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-06 Thread M Saleh EG
But why would you do that when you can share the Calendar over outlook?

On 6/6/05, [EMAIL PROTECTED] [EMAIL PROTECTED] 
wrote: 
 
 That looks like some of my code.. or a derivative of my code. For some 
 reason, my PC at work here is having issues with PHP instantiating with COM 
 so I can't test this, but the code you posted is conspicuously missing all 
 the braces { }. I'm guessing that's not your issue though... or else you'd 
 be getting some kind of error maybe.
 
 Anyway, here's a re-braced version of the code. It should produce 
 something when run through a web browser, but you might View Source and see 
 what shows up there.
 
 This does require Outlook to be installed on the PC that PHP is running 
 on, as that's how COM works. I never messed around with remote COM calls, 
 but I'm sure there's some way to do that.
 
 If someone wants to try this code and see if there are other issues 
 besides the missing braces. I don't see anything obviously wrong with it 
 (besides maybe some sloppy programming on my part :). I'll see about 
 checking it when I get home tonight if I have time.
 
 ?php
 $comobjOutlook = new COM(outlook.application) or die(Outlook not 
 loaded);
 
 //$comobjOutlook - Activate;
 
 # This is your mailbox name just like it appears in your Folders view.
 # It might be 'Inbox' or something else.
 $targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);
 
 
 # This is the folder you're looking for. In this case, I'm looking for 
 calendar
 # items, but you can look for any folder. You need to add another loop to 
 look
 # for subfolders. Although there's probably a better way, that's how I did 
 it when
 # I needed to get to Personal Folders/Inbox/Subfoldername
 $targetfoldername = Calendar;
 
 $objNamespace = $comobjOutlook-GetNameSpace(MAPI);
 $objFolders = $objNamespace-Folders();
 $mailboxcount = $objFolders - Count();
 
 
 $foundmailbox = FALSE;
 for ($i=1; $i=$mailboxcount; $i++) {
 $folderitem = $objFolders -Item($i);
 if ($folderitem - Name == $targetmailboxname) {
 $objMailbox = $folderitem;
 $foundmailbox = TRUE;
 
 $foundcal = FALSE;
 if ($foundmailbox) {
 $objFolders = $objMailbox-Folders();
 $foldercount = $objFolders - Count();
 
 for ($i=1; $i=$foldercount; $i++) {
 $folderitem = $objFolders - Item($i);
 if ($folderitem - Name == $targetfoldername) {
 $objCalendar = $folderitem;
 $foundcal = TRUE;
 }
 }
 }
 
 
 if ($foundcal) {
 $objItems = $objCalendar-Items();
 $itemcount = $objItems-Count();
 
 for ($i=1; $i=$itemcount; $i++) {
 $apptitem = $objItems - Item($i);
 $apptstart = $apptitem - Start();
 $apptend = $apptitem - End();
 $apptallday = $apptitem - AllDayEvent();
 $apptrecur = $apptitem - IsRecurring();
 $apptsubject = $apptitem - Subject();
 $apptlocation = $apptitem - Location();
 
 $secondsadj = $apptstart - 14400;
 $startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));
 
 $secondsadj = $apptend - 14400;
 $endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));
 
 if($apptallday) $allday = All Day; else $allday = ;
 if($apptrecur) $recurring = Recurring; else $recurring = ;
 
 echo $apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n;
 
 if ($allday   OR $recurring  ) echo $allday $recurring\r\n;
 echo \r\n\r\n;
 }
 } else {
 die (Did not find calendar folder);
 }
 } else {
 die(Did not find target mailbox: $targetmailboxname);
 }
 }
 ?
 
 
 
 = = = Original message = = =
 
 Hello all,
 
 I am trying to publish an Outlook Calendar on a web page using PHP and
 COM. I have managed to track down on the net some examples of how it
 could be done. The most promising is the code below. However, all that
 happens is that outlook.exe is started on the server, but nothing is
 displayed on the web page and it just times-out.
 
 I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
 installed on the server.
 Does anybody know why it doesn't work?
 
 Thanks
 Justin
 
 
 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
M.Saleh.E.G
97150-4779817


Re: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-06 Thread tg-php
Reasons:

1. Because you can.

2. Because I believe you need Exchange Server and IIS running to share outlook 
calendars out via the web(?)

3. Because the project has a requirement to do it this way

4. Because he likes a challenge



The question Is this the best way to accomplish your goal is a good one 
because if there's a smarter/better way, I'm sure even inflexible bosses can be 
made to bend a bit, but asking Why? always feels like someone's asking Are 
you a moron?  hah..  

-TG



= = = Original message = = =

But why would you do that when you can share the Calendar over outlook?

On 6/6/05, [EMAIL PROTECTED] [EMAIL PROTECTED] 
wrote: 
 
 That looks like some of my code.. or a derivative of my code. For some 
 reason, my PC at work here is having issues with PHP instantiating with COM 
 so I can't test this, but the code you posted is conspicuously missing all 
 the braces  . I'm guessing that's not your issue though... or else you'd 
 be getting some kind of error maybe.
 
 Anyway, here's a re-braced version of the code. It should produce 
 something when run through a web browser, but you might View Source and see 
 what shows up there.
 
 This does require Outlook to be installed on the PC that PHP is running 
 on, as that's how COM works. I never messed around with remote COM calls, 
 but I'm sure there's some way to do that.
 
 If someone wants to try this code and see if there are other issues 
 besides the missing braces. I don't see anything obviously wrong with it 
 (besides maybe some sloppy programming on my part :). I'll see about 
 checking it when I get home tonight if I have time.
 
 ?php
 $comobjOutlook = new COM(outlook.application) or die(Outlook not 
 loaded);
 
 //$comobjOutlook - Activate;
 
 # This is your mailbox name just like it appears in your Folders view.
 # It might be 'Inbox' or something else.
 $targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);
 
 
 # This is the folder you're looking for. In this case, I'm looking for 
 calendar
 # items, but you can look for any folder. You need to add another loop to 
 look
 # for subfolders. Although there's probably a better way, that's how I did 
 it when
 # I needed to get to Personal Folders/Inbox/Subfoldername
 $targetfoldername = Calendar;
 
 $objNamespace = $comobjOutlook-GetNameSpace(MAPI);
 $objFolders = $objNamespace-Folders();
 $mailboxcount = $objFolders - Count();
 
 
 $foundmailbox = FALSE;
 for ($i=1; $i=$mailboxcount; $i++) 
 $folderitem = $objFolders -Item($i);
 if ($folderitem - Name == $targetmailboxname) 
 $objMailbox = $folderitem;
 $foundmailbox = TRUE;
 
 $foundcal = FALSE;
 if ($foundmailbox) 
 $objFolders = $objMailbox-Folders();
 $foldercount = $objFolders - Count();
 
 for ($i=1; $i=$foldercount; $i++) 
 $folderitem = $objFolders - Item($i);
 if ($folderitem - Name == $targetfoldername) 
 $objCalendar = $folderitem;
 $foundcal = TRUE;
 
 
 
 
 
 if ($foundcal) 
 $objItems = $objCalendar-Items();
 $itemcount = $objItems-Count();
 
 for ($i=1; $i=$itemcount; $i++) 
 $apptitem = $objItems - Item($i);
 $apptstart = $apptitem - Start();
 $apptend = $apptitem - End();
 $apptallday = $apptitem - AllDayEvent();
 $apptrecur = $apptitem - IsRecurring();
 $apptsubject = $apptitem - Subject();
 $apptlocation = $apptitem - Location();
 
 $secondsadj = $apptstart - 14400;
 $startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));
 
 $secondsadj = $apptend - 14400;
 $endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));
 
 if($apptallday) $allday = All Day; else $allday = ;
 if($apptrecur) $recurring = Recurring; else $recurring = ;
 
 echo $apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n;
 
 if ($allday   OR $recurring  ) echo $allday $recurring\r\n;
 echo \r\n\r\n;
 
  else 
 die (Did not find calendar folder);
 
  else 
 die(Did not find target mailbox: $targetmailboxname);
 
 
 ?
 
 
 
 = = = Original message = = =
 
 Hello all,
 
 I am trying to publish an Outlook Calendar on a web page using PHP and
 COM. I have managed to track down on the net some examples of how it
 could be done. The most promising is the code below. However, all that
 happens is that outlook.exe is started on the server, but nothing is
 displayed on the web page and it just times-out.
 
 I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
 installed on the server.
 Does anybody know why it doesn't work?
 
 Thanks
 Justin


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Displaying an Outlook Calendar on a webpage using PHP

2005-06-06 Thread Justin.Baiocchi
Still no luck I am afraid. Same thing happens - it kicks off an instance
of Outlook.exe on the server, but the page never loads, it just stays
blank with a never-ending progress bar.

I thought it could be security related but have shared out my Calendar
with default having reviewer access.

I am using an Exchange server but don't want to follow the route of
sharing Calendars and accessing them in Outlook. 

Is the problem with the script that it has to access an Exchange server
to read the Calendar, even while Outlook is installed on the server and
configured with the same profile?

Thanks
Justin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 7 June 2005 1:01 AM
To: php-general@lists.php.net
Cc: Baiocchi, Justin (CSIRO IT, Armidale)
Subject: Re: [PHP] Displaying an Outlook Calendar on a webpage using PHP


That looks like some of my code.. or a derivative of my code.   For some
reason, my PC at work here is having issues with PHP instantiating with
COM so I can't test this, but the code you posted is conspicuously
missing all the braces { }.  I'm guessing that's not your issue
though... or else you'd be getting some kind of error maybe.

Anyway, here's a re-braced version of the code.   It should produce
something when run through a web browser, but you might View Source and
see what shows up there.

This does require Outlook to be installed on the PC that PHP is running
on, as that's how COM works.   I never messed around with remote COM
calls, but I'm sure there's some way to do that.

If someone wants to try this code and see if there are other issues
besides the missing braces.  I don't see anything obviously wrong with
it (besides maybe some sloppy programming on my part :).  I'll see about
checking it when I get home tonight if I have time.

?php
$comobjOutlook = new COM(outlook.application) or die(Outlook not
loaded);

//$comobjOutlook - Activate;

# This is your mailbox name just like it appears in your Folders view.
# It might be 'Inbox' or something else.
$targetmailboxname = Mailbox - Baiocchi, Justin (CSIRO IT, Armidale);


# This is the folder you're looking for. In this case, I'm looking for
calendar
# items, but you can look for any folder. You need to add another loop
to look
# for subfolders. Although there's probably a better way, that's how I
did it when 
# I needed to get to Personal Folders/Inbox/Subfoldername
$targetfoldername = Calendar;

$objNamespace = $comobjOutlook-GetNameSpace(MAPI);
$objFolders = $objNamespace-Folders();
$mailboxcount = $objFolders - Count();


$foundmailbox = FALSE;
for ($i=1; $i=$mailboxcount; $i++) {
  $folderitem = $objFolders -Item($i);
  if ($folderitem - Name == $targetmailboxname) {
$objMailbox = $folderitem;
$foundmailbox = TRUE;

$foundcal = FALSE;
if ($foundmailbox) {
  $objFolders = $objMailbox-Folders();
  $foldercount = $objFolders - Count();

  for ($i=1; $i=$foldercount; $i++) {
$folderitem = $objFolders - Item($i);
if ($folderitem - Name == $targetfoldername) {
  $objCalendar = $folderitem;
  $foundcal = TRUE;
}
  }
}


if ($foundcal) {
  $objItems = $objCalendar-Items();
  $itemcount = $objItems-Count();

  for ($i=1; $i=$itemcount; $i++) {
$apptitem = $objItems - Item($i);
$apptstart = $apptitem - Start();
$apptend = $apptitem - End();
$apptallday = $apptitem - AllDayEvent();
$apptrecur = $apptitem - IsRecurring();
$apptsubject = $apptitem - Subject();
$apptlocation = $apptitem - Location();

$secondsadj = $apptstart - 14400;
$startadj = date(m/d/Y H:i:s,
mktime(0,0,$secondsadj,1,1,1970));

$secondsadj = $apptend - 14400;
$endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970));

if($apptallday)  $allday = All Day;  else  $allday = ;
if($apptrecur)  $recurring = Recurring;  else  $recurring =
;

echo $apptsubject @ $apptlocation\r\nFrom: $startadj To:
$endadj\r\n;

if ($allday   OR $recurring  ) echo $allday
$recurring\r\n;
echo \r\n\r\n;
  }
} else {
  die (Did not find calendar folder);
}
  } else {
die(Did not find target mailbox: $targetmailboxname);
  }
}
?



= = = Original message = = =

Hello all,
 
I am trying to publish an Outlook Calendar on a web page using PHP and
COM. I have managed to track down on the net some examples of how it
could be done. The most promising is the code below. However, all that
happens is that outlook.exe is started on the server, but nothing is
displayed on the web page and it just times-out.
 
I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
installed on the server.
Does anybody know why it doesn't work?
 
Thanks 
Justin


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--
PHP