0

Error -:

New-Object : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)). At D:\get-process.ps1:5 char:12 + $Outlook = New-Object -ComObject Outlook.Application + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (:) [New-Object], COMExcept ion + FullyQualifiedErrorId : NoCOMClassIdentified,Microsoft.PowerShell.Comman ds.NewObjectCommand You cannot call a method on a null-valued expression. At D:\get-process.ps1:6 char:1 + $Mail = $Outlook.CreateItem(0) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull The property 'To' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:8 char:1 + $Mail.To = "$username" + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound The property 'Subject' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:9 char:1 + $Mail.Subject = "New Leave Request" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound The property 'Body' cannot be found on this object. Verify that the property exists and can be set. At D:\get-process.ps1:10 char:1 + $Mail.Body = "$username" + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound You cannot call a method on a null-valued expression. At D:\get-process.ps1:12 char:1 + $Mail.Send() + ~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Hello [email protected]

get-process.php -:

<?php

    $username = "[email protected]";

    $psScriptPath = "D:\\get-process.ps1";

    $query = shell_exec("powershell -command $psScriptPath -username '$username'< NUL");
    echo $query;

?>

get-process.ps1 -:

param(
[string]$username
)

$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)

$Mail.To = "$username"
$Mail.Subject = "New Leave Request"
$Mail.Body = "$username"

$Mail.Send()

Write-Output "Hello $username <br />"

get-process.php is the php that is present in root folder wwwroot of IIS Windows Server 2012 and from which the PowerShell script get-process.ps1 is triggered. Get-process.ps1 contains script for sending the mail

9
  • Format your erroe, it's unreadable Commented Jul 28, 2015 at 6:38
  • @Hearner error came like this only Commented Jul 28, 2015 at 6:43
  • Ensure the app pool runs under your account and try to set the "Enable the 32-Bit Applications" property to True Commented Jul 28, 2015 at 7:01
  • You may also take a look at this: stackoverflow.com/questions/15198239/… Commented Jul 28, 2015 at 7:04
  • @jisaak can you provide me an alternative for sending mail using php I have to extract the values from database and hence send mail containing those values on iis windows server 2012 Commented Jul 28, 2015 at 7:09

1 Answer 1

1

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

Instead, you may consider using a low-level API on which Outlook is based on - Extended MAPI. Or any other wrapper around that API, for example, Redemption.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.