Powershell Script[script1.ps1] -:
param(
[string]$username,
[string]$username1,
)
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "$username1"
$Mail.Cc = "$username"
$Mail.Subject = "SUBJECT"
$Mail.Body = "--content--"
$mail.VotingOptions = "Approve;Reject"
$Mail.Send()
Php Code -:
<?php
$connection = oci_connect("username","password","db_name");
$lname = $_SESSION['lead_name'];
$main_query=oci_parse($connection,"SELECT * FROM TABLE WHERE FIELD= '$lname'");
oci_execute($main_query,OCI_DEFAULT);
while($res = oci_fetch_array($main_query))
{
$mail= $res['USERNAME'];
}
$_SESSION['mail_id']=$mail;
$cc = $_SESSION['mail'];
$username = $cc;
$username1 = $_SESSION['mail_id'];
$psScriptPath = "C:\\xampp\\htdocs\\Website_LMS\\Powershell\\script1.ps1";
$query = shell_exec("powershell -command $psScriptPath -username '$username'< NUL -username1 '$username1'< NUL");
oci_close($connection);
?>
Powershell Script is used to send email to outlook. All these parameters username,username1 are sent from php script via shell exec command. These two are email address.
Now i want to use the voting button to approve or reject a leave which is triggered to the email addresses menetioned. I want the voting button is sent to username1 only i.e "To" addresses and not to "cc" addresses. I want to implement this via powershell.
Since the voting buttons (= the information on what to vote) are part of the mail, like the text and the subject, it is not possible to just make them visible to some of the recipients. Outlook (or better, the server, most likely Exchange) will send the very same email to all recipients, regardless whether they are addressed via
To
,Cc
orBcc
.That's by design, as stated in RFC2822 (Internet Message Format):
You can simply send two Mails with the same content, except for the buttons:
To clear things up for the recipients, you could add a text to the mails, stating that this mail is also sent to
$username
.