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

0

Holo

I have the nex problem trying to make automatic mailer from website for failure system.

I have WAMP and my code is on php that do many thing, the main porpouse is that this php file crete *.ps1 (Powershell mail), the second part create the *.bat (file that execute *.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"

This two program work perfectly and i cand send automatic mail, but when i try to execute from web i get this error, i enable userdir_module on apache.

ERROR ->

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

I hope any one have and idea, i continue trying and reading more about this.

Thanks (My english is regular), have a nice night.

php
powershell
batch-file
outlook
wamp
asked on Stack Overflow Jul 5, 2013 by user2555142

1 Answer

0

A quick Google Search for HRESULT 0x80004004 shows that Outlook won't let you do this.. Instead, try using PowerShell's Send-MailMessage:

Send-MailMessage -Priority High `
                 -Subject "bla bla blah" `
                 -Body "bla bla blah" `
                 -To "email"
answered on Stack Overflow Jul 9, 2013 by Aaron Jensen

User contributions licensed under CC BY-SA 3.0