WAMP + PHP + PowerShell 2.0 + bat + Outlook + HRESULT:0x80004004(E_ABORT)

时间:2013-07-05 23:07:11

标签: php powershell batch-file outlook wamp

全息

我有尝试从网站上为故障系统制作自动邮件的nex问题。

我有WAMP,我的代码在php上做了很多事情,主要的porpouse是这个php文件crete * .ps1(Powershell邮件),第二部分创建* .bat(执行* .ps1的文件)

* .ps1 - >

$o = New-Object -com Outlook.Application
$mail = $o.CreateItem(0)
$mail.importance = 2
$mail.subject = "bla bla bla"
$mail.body = "bla bla bla"
$mail.To = "email"
$mail.Send()

*。bat - >

@echo off
"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\PowerShell.exe" -File "*.ps1" > "ok.log" 2> "error.log"

这两个程序完美地运行并且我发送自动邮件,但是当我尝试从web执行时我得到此错误,我在apache上启用userdir_module。

错误 - >

Excepci¢n al llamar a "Send" con los argumentos "0": "Operaci¢n anulada (Excepc
i¢n de HRESULT: 0x80004004 (E_ABORT))"
En *.ps1: 9 Car cter: 11
+ $mail.Send <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation

我希望任何人都有想法,我会继续尝试并阅读更多有关此事的内容。

谢谢(我的英语很正常),祝你有个美好的夜晚。

1 个答案:

答案 0 :(得分:0)

快速Google搜索HRESULT 0x80004004会显示Outlook won't let you do this.。相反,请尝试使用PowerShell的Send-MailMessage

Send-MailMessage -Priority High `
                 -Subject "bla bla blah" `
                 -Body "bla bla blah" `
                 -To "email"