I'm looking to use the default Windows 7 Outlook 2010 mail account to send an email.
I've tried:
oApp = new COM("Outlook.Application") or die('error');
$oMsg = $oApp ->CreateItem($oApp->OlItemType->olMailItem);
$oMsg ->Recipients->Add("[email protected]");
$oMsg ->Subject="aaaa";
$oMsg ->Body="body";
$oMsg ->Save();
$oMsg ->Send();
But I get the error:
Outlook loaded, version 14.0.0.7109
Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup
`OlItemType': Unknown name. ' in C:\xampp\htdocs\Intranet_IT_Request_Form
\comunread.php:5 Stack trace: #0 C:\xampp\htdocs\Intranet_IT_Request_Form
\comunread.php(5): unknown() #1 {main} thrown in C:\xampp\htdocs
\Intranet_IT_Request_Form\comunread.php on line 5
My research tells me I need cdo.dll, which contains all the email functions, but I can only install this with Outlook 2007; not practical at all.
Does anyone know how to send an Outlook 2010 email using PHP? (I'm using XAMPP).
Many many thanks
This works:
if (!defined("olMailItem")) {define("olMailItem",0);}
$oApp = new COM("Outlook.Application") or die('error');
$oMsg = $oApp->CreateItem(olMailItem);
$oMsg->Recipients->Add("[email protected]");
$oMsg->Subject=$subject;
$oMsg->Body=$message;
$oMsg->Save();
$oMsg->Send();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With