我创建了一个小的C#控制台应用发送使用前景,这是非常简单的需要从PHP代码调用如何使用outlook和php发送邮件?
Outlook.Application oApp = new Outlook.Application();
//Create the new message by using the simplest approach.
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.Recipients.Add("[email protected]"); //////////////////problem line
oMsg.Subject = "aaaa";
oMsg.Body = "body";
//Send the message.
oMsg.Save();
oMsg.Send();
此代码的邮件。
1)它在控制台中工作得很好。
2)当我从PHP调用我得到一个错误。我注意到,这个控制台应用程序,当从PHP调用将运行在系统用户。所以我做了outlook的系统运行,但我仍然得到这个错误。我正在运行Apache服务器。
System.Runtime.InteropServices.COMException(0x80004004):操作中止(从HRESULT异常:0x80004004(E_ABORT)) 在Microsoft.Office.Interop.Outlook._MailItem.get_Recipients() 在SyncEmail.Program.sendMailUsingOutlook(字符串收件人,字符串正文,字符串主题)在D:\ NotEncrypted \ Projects \ SyncEmail \ SyncEmail \ Program.cs:行121
我拉我的头发看着不同的事情。任何帮助,将不胜感激。感谢您阅读我的文章。
当我说一些人说使用PHP我决定去PHP路线,并写下这段代码,并得到相同的错误。
if (!defined(‘olMailItem’)) define(“olMailItem”,0);
$objApp = new COM(“Outlook.Application”);
$myItem = $objApp->CreateItem(olMailItem);
$myItem->To=’[email protected]’;
$myItem->SentOnBehalfOfName = ‘[email protected]’;
$myItem->Subject=”This is a test”;
$myItem->Body=”This is a Body Section now…..!”;
$myItem->Send();
我得到这个错误
致命错误:未捕获的异常 '发出com_exception' 与消息“中d:\ NotEncrypted \ XAMPP \ htdocs中\铜\ SYSTEM \模块\项目\的index.php上线11251 发出com_exception(!):错误[0x80004004]操作中止在d:\ NotEncrypted \ XAMPP \ htdocs中\铜\ SYSTEM \模块\ \项目上线的index.php 11251
有没有我可以用它来阅读的任何链接这个。我是新来的PHP谢谢你的帮助。 – 2012-04-24 22:14:50
https://www.google.com.ng/search?sourceid=chrome&ie=UTF-8&q=php+Outlook.Application这将有助于 – Baba 2012-04-24 22:17:58
致命错误:在D:\ NotEncrypted \ xampp中未捕获异常'com_exception'消息'' \ htdocs \ copper \ system \ modules \ projects \ index.php 11251行(!)com_exception:错误[0x80004004]在D:\ NotEncrypted \ xampp \ htdocs \ copper \ system \ modules \ projects \ index.php中中止操作line 11251 ----------------我在我原来的帖子中使用了php代码。我从.net代码和php代码得到的错误是相同的,我想..谢谢。 – 2012-04-25 17:04:23