outlook and php

Reply

Join Date: Apr 2005
Posts: 183
Reputation: hbmarar is an unknown quantity at this point 
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

outlook and php

 
0
  #1
Apr 21st, 2005
hi,

i had got a script from some resource that demonstrasted outlook and php.
but i had done perfectly but getting the following error.

I request members to help me with this.
Fatal error:
Uncaught exception 'com_exception' with message 'Parameter 0: Type mismatch. ' in C:\apachefriends\xampp\htdocs\outlook\COutlook.php:112 Stack trace: #0 C:\apachefriends\xampp\htdocs\outlook\COutlook.php(112): variant->GetDefaultFolder('olFolderInbox') #1 C:\apachefriends\xampp\htdocs\outlook\COutlook.php(129): COutLook->getUnreadinInbox() #2 C:\apachefriends\xampp\htdocs\outlook\comunread.php(10): COutLook->staticFolders() #3 {main} thrown in C:\apachefriends\xampp\htdocs\outlook\COutlook.php on line 112


Thanking all of you for the concern and consideration in advance ,I remain

really in need of help.

Hari
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 13
Reputation: I_love_me780 is an unknown quantity at this point 
Solved Threads: 1
I_love_me780's Avatar
I_love_me780 I_love_me780 is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #2
Apr 21st, 2005
try calling your local internet service provider
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 18
Reputation: demo is an unknown quantity at this point 
Solved Threads: 2
demo demo is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #3
Apr 26th, 2005
Do you have the code?

The problem is that the object method is expecting a certain type of 'VARIANT' and the one you passed is not correct. If you have the code I can show you how to fix your problem!

demo
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 183
Reputation: hbmarar is an unknown quantity at this point 
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: outlook and php

 
0
  #4
Apr 27th, 2005
Originally Posted by demo
Do you have the code?

The problem is that the object method is expecting a certain type of 'VARIANT' and the one you passed is not correct. If you have the code I can show you how to fix your problem!

demo
Yes,I can share it with you and thanks for the concern xtended by u.
I am providing the codes.

<?PHP

global $UnreadMessagesInFolder;
class COutLook{
//function for retreiving messages from the selected folder (Inbox or Outbox)
function getMessages($folder){


//Setup the folder table,.there is 4 elements:

//message number,message subject ,message type and date received


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>";

//creating the COM instance for Outlook.application and MAPI session(access the outlook folders object)
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");


//Log into the session like default user
$session->Logon();

//selecting working folder Inbox ot Outbox/
$inb=$session->$folder;

//get the total messages in Folder
$messages=$inb->Messages->Count();

//get the elements of the message object

for($i=1;$i<($messages+1);$i++){


$item=$inb->Messages->item($i);


//date string
$timeres=$item->TimeReceived();
$date_vb=getdate($timeres);


//date elements
$year=$date_vb['year'];
$month=$date_vb['mon'];
$day=$date_vb['mday'];


//entering the folder elements
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>";
}
echo"</table>";
}



//view mesage from selected folder (Inbox or Outbox)


function ViewMessageFromFolder($id,$folder){
//create new instance of the COM Objects
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");


//Log into the current working session
$session->Logon();

//get default folder
$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>";
}
else{
$idint=(int)$id;

//get the messages in the selested folder
$items=$inb->Messages->item($idint);


//make message status read= true
$items->Unread="false";


//Update the message status into Outlook's Inbox
$items->Update(true);


//display the message

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>";
}
}

function getUnreadinInbox(){


//get unread messages from the Inbox Folder
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderInbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;
}

function getUnreadinOutbox(){
//get unread messages from the Outbox Folder
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderOutbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;

}

function staticFolders(){
// List of the avaailable folders (static !!!)
$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>";
}


//end of classs
}
?>

thanking you once again ....and expecting your help sincerely

Harish Balakrishnan Marar
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1
Reputation: DocTrax is an unknown quantity at this point 
Solved Threads: 0
DocTrax DocTrax is offline Offline
Newbie Poster

Re: outlook and php

 
1
  #5
Jul 7th, 2005
Der Fehler kommt in dem Code aber nicht vor!
variant->GetDefaultFolder('olFolderInbox') muss heissen
variant->GetDefaultFolder(olFolderInbox) und ist im Code richtig.
olFolderInbox müsste dann eine Konstante sein.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1
Reputation: cucola is an unknown quantity at this point 
Solved Threads: 0
cucola cucola is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #6
Mar 12th, 2007
Originally Posted by hbmarar View Post
Yes,I can share it with you and thanks for the concern xtended by u.
I am providing the codes.

<?PHP

global $UnreadMessagesInFolder;
class COutLook{
//function for retreiving messages from the selected folder (Inbox or Outbox)
function getMessages($folder){


//Setup the folder table,.there is 4 elements:

//message number,message subject ,message type and date received


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>";

//creating the COM instance for Outlook.application and MAPI session(access the outlook folders object)
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");


//Log into the session like default user
$session->Logon();

//selecting working folder Inbox ot Outbox/
$inb=$session->$folder;

//get the total messages in Folder
$messages=$inb->Messages->Count();

//get the elements of the message object

for($i=1;$i<($messages+1);$i++){


$item=$inb->Messages->item($i);


//date string
$timeres=$item->TimeReceived();
$date_vb=getdate($timeres);


//date elements
$year=$date_vb['year'];
$month=$date_vb['mon'];
$day=$date_vb['mday'];


//entering the folder elements
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>";
}
echo"</table>";
}



//view mesage from selected folder (Inbox or Outbox)


function ViewMessageFromFolder($id,$folder){
//create new instance of the COM Objects
$oOutlook = new COM("Outlook.Application");
$session= new COM("MAPI.Session");


//Log into the current working session
$session->Logon();

//get default folder
$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>";
}
else{
$idint=(int)$id;

//get the messages in the selested folder
$items=$inb->Messages->item($idint);


//make message status read= true
$items->Unread="false";


//Update the message status into Outlook's Inbox
$items->Update(true);


//display the message

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>";
}
}

function getUnreadinInbox(){


//get unread messages from the Inbox Folder
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderInbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;
}

function getUnreadinOutbox(){
//get unread messages from the Outbox Folder
$oOutlook = new COM("Outlook.Application");
$oNs = $oOutlook->GetNamespace("MAPI");
$oFldr = $oNs->GetDefaultFolder(olFolderOutbox);
$UnreadMessagesInFolder = $oFldr->UnReadItemCount;
return $UnreadMessagesInFolder;

}

function staticFolders(){
// List of the avaailable folders (static !!!)
$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>";
}


//end of classs
}
?>

thanking you once again ....and expecting your help sincerely

Harish Balakrishnan Marar
You have referenced 2 Outlook variables by their names, olFolderInbox and olFolderOutbox. These names are not recognised outside of Outlook, so you must use their values instead. olFolderInbox = 6 and olFolderOutbox = 4
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 2
Reputation: mmmbop is an unknown quantity at this point 
Solved Threads: 0
mmmbop mmmbop is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #7
Mar 13th, 2007
Hi there,
I have been trying desperately to implement ‘Accessing an Outlook account/profile using PHP’. I believe the com object implementation will offer me the best solution. This is where the problem lies, even though I have copied the code and removed all comments, added in my username and password to the $session->logon() and it now comes back with an error (‘cdo.dll has been registered on my local pc, however not on the server’)… the error is as follows :

Fatal error: Uncaught exception 'com_exception' with message 'Parameter 0: Type mismatch. ' in C:\wamp\www\Training\COutLook.php:104 Stack trace: #0 C:\wamp\www\Training\COutLook.php(104): variant->GetDefaultFolder('olFolderInbox') #1 C:\wamp\www\Training\COutLook.php(121): COutLook->getUnreadinInbox() #2 C:\wamp\www\Training\comunread.php(10): COutLook->staticFolders() #3 {main} thrown in C:\wamp\www\Training\COutLook.php on line 104

If you can offer any assistance with this error it would be greatly appreciated… if your need the scripts to interpret the error they can be found at

http://www.digiways.com/articles/php/outlook/

Thank you very much for your time
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 1
Reputation: magnum129 is an unknown quantity at this point 
Solved Threads: 0
magnum129 magnum129 is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #8
Mar 24th, 2007
try using webdav for access to exchange google "webdav troy wolf"
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1
Reputation: bharanikumarphp is an unknown quantity at this point 
Solved Threads: 0
bharanikumarphp bharanikumarphp is offline Offline
Newbie Poster

Re: outlook and php

 
0
  #9
Dec 23rd, 2008
Hi hbmarar


Can u please give the outlook and php code,

Its very urgent ,

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC