如何使PHP Outlook.Application工作并发送邮件? [英] how to make php Outlook.Application work and send mail?

查看:196
本文介绍了如何使PHP Outlook.Application工作并发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if (!defined(‘olMailItem’)) define("olMailItem",0);
$objApp = new COM("Outlook.Application");
$myItem = $objApp->CreateItem(olMailItem);
$myItem->To=’xxxx@xxx.com’;
$myItem->SentOnBehalfOfName = ‘yyy@xxyyx.com’;
$myItem->Subject="This is a test";
$myItem->Body="This is a Body Section now…..!";
$myItem->Send();

我收到此错误

致命错误:第11251行(!)D:\ NotEncrypted \ xampp \ htdocs \ copper \ system \ modules \ projects \ index.php中消息'在未捕获的异常'com_exception'中,消息com_exception:错误[0x80004004]操作在第11251行的D:\ NotEncrypted \ xampp \ htdocs \ copper \ system \ modules \ projects \ index.php

Fatal error: Uncaught exception ‘com_exception’ with message ‘ in D:\NotEncrypted\xampp\htdocs\copper\system\modules\projects\index.php on line 11251 ( ! ) com_exception: Error [0x80004004] Operation aborted in D:\NotEncrypted\xampp\htdocs\copper\system\modules\projects\index.php on line 11251

谢谢您的评论和帮助.

推荐答案

您的Outlook组件服务很可能没有运行

Most likely your Outlook Component Service is not running

运行

  Start -> run -> dcomcnfg.exe 

查看其是否存在

如果MAPI.Session可用,您还需要检查Windows注册表

You also need to check your windows Registry if MAPI.Session is available

 Start -> Run -> HKEY_CLASSES_ROOT  -> Outlook.Application -> MAPI.Session 

如果找不到,请使用本教程

If you can't find this then use this tutorials

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

示例

set_time_limit(10);

if (! defined ( "olMailItem" ))
{
    define ("olMailItem", 0 );
}

try {
    $objApp = new COM ( "Outlook.Application" ) or die ( "Cannot Load Outlook.Application" );
    $namespace = $objApp->GetNamespace("MAPI");  // or MAPI.Session
    $namespace->Logon();
    $myItem = $objApp->CreateItem ( olMailItem );
    $myItem->To = "xxxx@xxx.com";
    $myItem->SentOnBehalfOfName = "yyy@xxyyx.com";
    $myItem->Subject = "This is a test";
    $myItem->Body = "This is a Body Section now…..!";
    $myItem->Send ();

} catch ( Exception $e ) {
    var_dump ( $e->getMessage () );
    debug_print_backtrace ();
}

我希望对您有帮助

这篇关于如何使PHP Outlook.Application工作并发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆