I'm trying to use PHP5 to create new OUtlook email messages, add some recipients, subject, and message in body, and maybe attach a file. Has anyone had any success with this?
I found one person from Bulgaria that has some code for this.. However, it doesn't seem to work. I've pasted it below to see if you can get it to work..
------------------------------
$objApp = new COM("Outlook.Application") or die("Unable to instantiate Outlook");;
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("[email protected]");
$myItem->Subject="PHP5 This is a test";
$myItem->Body="This is a Body Section now.....!";
$myItem->Display();
$myItem->Send();
----------------------------------
Any help is greatly appreciated..maybe you should define useful constants like this
define("olAppointmentItem",1);
define("olContactItem",2);
define("olDistributionListItem",7);
define("olJournalItem",4);
define("olMailItem",0);
define("olNoteItem",5);
define("olPostItem",6);
define("olTaskItem",3);
com_load_typelib('Outlook.Application');
$objApp = new COM("Outlook.Application");
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("a_mail@a_domain.fr");
$myItem->Subject="Subject";
$myItem->Body="This is a Body Section now.....!";
//$myItem->Display();
$myItem->Send();
It seems it's not a problem, with php < 4.2
but with php 5 it doesn't work for me, sometimes the mail is sended but most of time not, and it crashes apache in any case (or php itself if i launch this script from cmd line)
I found one person from Bulgaria that has some code for this.. However, it doesn't seem to work. I've pasted it below to see if you can get it to work..
------------------------------
$objApp = new COM("Outlook.Application") or die("Unable to instantiate Outlook");;
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("[email protected]");
$myItem->Subject="PHP5 This is a test";
$myItem->Body="This is a Body Section now.....!";
$myItem->Display();
$myItem->Send();
----------------------------------
Any help is greatly appreciated..maybe you should define useful constants like this
define("olAppointmentItem",1);
define("olContactItem",2);
define("olDistributionListItem",7);
define("olJournalItem",4);
define("olMailItem",0);
define("olNoteItem",5);
define("olPostItem",6);
define("olTaskItem",3);
com_load_typelib('Outlook.Application');
$objApp = new COM("Outlook.Application");
$myItem = $objApp->CreateItem(olMailItem);
$a=$myItem->Recipients->Add("a_mail@a_domain.fr");
$myItem->Subject="Subject";
$myItem->Body="This is a Body Section now.....!";
//$myItem->Display();
$myItem->Send();
It seems it's not a problem, with php < 4.2
but with php 5 it doesn't work for me, sometimes the mail is sended but most of time not, and it crashes apache in any case (or php itself if i launch this script from cmd line)