Attach a php file to a frame in Dreamweaver

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

Post Reply
Catherine
Forum Newbie
Posts: 11
Joined: Mon Feb 09, 2004 2:57 am

Attach a php file to a frame in Dreamweaver

Post by Catherine »

Hi there,

I am trying to open MS Outlook using PHP and Dreamweaver. I have found some very good code on the web but don't understand the last part

"to make a file called index.php which has two frames, in the main frame put the file comunread.php and in the bottom frame put view.php."

I don't understand what they mean by this as I am new to using PHP and Dreamweaver.

Any help would be greatly appreciated. Thanks

Catherine
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

save this code in the file called index.php

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<frameset rows="*,80" frameborder="NO" border="0" framespacing="0">
  <frame src="comunread.php" name="mainFrame">
  <frame src="view.php" name="bottomFrame" scrolling="NO" noresize>
</frameset>

</html>
Mark
Catherine
Forum Newbie
Posts: 11
Joined: Mon Feb 09, 2004 2:57 am

Post by Catherine »

Hi Mark

Thanks for that, but when i try to run it, I get these errors:

Warning: (null)(): Unable to obtain IDispatch interface for CLSID {0006F03A-0000-0000-C000-000000000046}: Server execution failed in c:\program files\apache group\apache\htdocs\COutLook.php on line 70

Fatal error: Maximum execution time of 30 seconds exceeded in c:\program files\apache group\apache\htdocs\COutLook.php on line 70

These are the lines of code where it gives the errors

function getUnreadinInbox()
{
$oOutlook = new COM("Outlook.Application"); ///LINE 70
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderInbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;
}

Thanks again for your help

Catherine
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what script is this that you have got?

Basically, the script is unable to open Outlook. The COM objects are a pain in the ass. You will have to check the permissions for PHP to be allowed to access the application.

What OS are you running?

Mark
Catherine
Forum Newbie
Posts: 11
Joined: Mon Feb 09, 2004 2:57 am

Post by Catherine »

In the php.ini file the COM is set to true

The OS is Microsoft Windows XP Home Edition and I am using MS Outlook 2000


The script is COutlook

<?PHP
global $UnreadMessagesInFolder;
global $folder;
class COutLook{

function getMessages($folder){
?>
echo"<body text=darkblue>
<br><font color=red face=verdana size=3><b>$folder</b></font>
<table width=100%>
<TR bgcolor=#EEEFFF><td><font face=verdana size=2>N:</td><td>
<font face=verdana size=2> Subject</td><TD>
<font face=verdana size=2 >Type</TD><TD><font face=verdana size=2> Date</TD></TR>";
<?PHP
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");
$session->Logon();
$inb=$session->$folder;
$messages=$inb->Messages->Count();

for($i=1;$i<($messages+1);$i++)
{
$item=$inb->Messages->item($i);
$timeres=$item->TimeReceived();
$date_vb=getdate($timeres);
$year=$date_vb['year'];
$month=$date_vb['mon'];
$day=$date_vb['mday'];
?>
echo "<tr bgcolor=#F0F0F0><td><font face=verdana size=2 color=darkblue>$i</td><td><font face=verdana size=2 color=darkblue>
<a href=view.php?id=$i&folder=$folder target=bottomFrame><font face=verdana size=2 color=#FF6666>$item->Subject</font></td><td><font face=verdana size=2 color=darkblue>$item->Type</td><td><font face=verdana size=1 color=darkblue>$year/$month/$day</td></font><tr>";
<?PHP
}
?>
echo"</table>";
<?PHP
}

function ViewMessageFromFolder($id,$folder)
{
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");
$session->Logon();
$inb=$session->$folder;

if($id=="")
{
?>
echo "<font face=verdana size=2 color=darkblue>Message Viewer</font><br><font face=verdana size=2 color=red><center>No Messages Selected</center></font>";
<?PHP
}
else
{
$idint=(int)$id;
$items=$inb->Messages->item($idint);
$items->Unread="false";
$items->Update(true);
?>

echo"<font face=verdana size=2 color=darkblue>Message Viewer</font>";
echo"<table width=100%><tr><td><font face=verdana size=2 color=darkblue>$i</td><td><font face=verdana size=2 color=darkblue>
<b>$items->Subject</b></td><td><font face=verdana size=2 color=darkblue>$items->Type</td><td></td></font><tr>
<tr><td colspan=4><pre><font face=verdana size=2 color=darkblue>$items->Text</pre></td></tr>";
<?PHP
}
}

function getUnreadinInbox()
{
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderInbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;
}

function getUnreadinOutbox()
{
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderOutbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;
}

function staticFolders()
{
$unread=$this->getUnreadinInbox();
$out_unr=$this->getUnreadinOutbox();
?>
echo"<font color=blue face = verdana size=1>Available folders in this version are:
<a href=comunread.php?folder=Inbox>Inbox(<font color=red>$unread</font>)</a>
and <a href=comunread.php?folder=Outbox>Outbox(<font color=red>$out_unr</font>)</a></font>";
<?PHP
}

}
?>


The comuread.php is

<html>
<?PHP
require("COutLook.php");
$class= new COutLook;
if ($folder==""){
$class->staticFolders();
}
else {
$class->staticFolders();
$class->getMessages($folder);
}

?>
<\html>


The view.php is

<?PHP

require("COutLook.php");
$class= new COutLook;
if ($id=="" || $folder== ""){
?>
<font face=verdana size=2 color=darkblue>Message Viewer</font>
<br><font face=verdana size=2 color=red>
<center>No Messages Selected</center></font></br>
<?PHP
}

else
{
$class->ViewMessageFromFolder($id,$folder);
}
?>

then i run the index.php with the code you gave me.

If you have any other suggestions I would be more than happy to take them on board.

This is for a final year project in college and I am running it off a laptop and using the phone line at home to connect to the internet.

Thanks again for your help
Catherine
Catherine
Forum Newbie
Posts: 11
Joined: Mon Feb 09, 2004 2:57 am

Opening Outlook using PHP

Post by Catherine »

Hi Mark

just wondering if you had any luck with the code that I sent yesterday because I am still having problems.

Thanks
Catherine
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

sorry, i really don't have time to try and recreate your problem

Maybe you could contact the author of the script.

Also, have a look at the COM function in the PHP manual. Especiall read the user comments, there maybe some stuff to help in the - http://se.php.net/manual/en/ref.com.php

Mark
Post Reply