您好,需要准备 Outlook 电子邮件草稿并在 Outlook 中打开它。
我已经创建了 php 表单来运行 powershell 的供应变量,该 powershell 调用 Outlook 方法并创建电子邮件。
当我执行如下所示的 powershell 时
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe C:\wamp\www\bizops\prepare_email.ps1 >> C:\wamp\www\bizops\log.log
它完美地工作。
但是当我将上面的行放在一个批处理文件中并在 PHP 脚本中调用它时,
$mail_string="c:\WINDOWS\system32\cmd.exe /c START C:\wamp\www\bizops\outlook_mail.bat";
exec($mail_string);
它给了我以下错误
New-Object : Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following error:
80080005 Server execution failed (Exception from HRESULT: 0x80080005
(CO_E_SERVER_EXEC_FAILURE)).At C:\wamp\www\bizops\prepare_email.ps1:25 char:7
+ $ol = New-Object -comObject Outlook.Application
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [New-Object], COMException
+ FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand
我的 powershell 代码看起来像(抛出此错误的部分)
$ol = New-Object -comObject Outlook.Application
$ns = $ol.GetNameSpace("MAPI")
$Mail = $ol.CreateItem(0)
$Mail.Recipients.Add($mail_to_list)
$mail.Subject = $mail_subject
$mail.DeferredDeliveryTime = $deliverAt
$Mail.HTMLBody = "SOME HTML TEXT"
虽然花了很长时间才找到解决方案,因为错误不清楚。如果问题是由于许可未匹配或其他原因引起的,则存在混淆。
我很高兴能够找到解决此问题的方法。
我们需要通过有效用户运行 httpd(您可能需要创建一个单独的用户 t 来运行您的任务)。在此处输入图片说明
希望截图能说清楚
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句