How to limit the vote button to "To" instead of sending "Cc" to Outlook via powershell?

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 the exec exec command. These are two email addresses.

Now I want to use the vote button to approve or reject a vacation that runs on the specified email addresses. I want the vote button to be sent to username1 only ie "To" and not "cc". I want to implement this through powershell.

+5
source share
1 answer

Since the voting buttons (= information about voting) are part of the mail, like text and subject, it is impossible to simply make them visible to some of the recipients. Outlook (or, better, a server, most likely Exchange) will send the same address to all recipients, regardless of whether they are addressed through To , Cc or Bcc .

This is by design, as indicated in RFC2822 (Internet Message Format) :

Destination fields indicate the recipients of the message. each destination field may have one or more addresses, and each address indicates the intended recipients of the message. The only difference between the three fields is how they are used.

You can simply send two mails with the same contents, with the exception of buttons:

 param( [string]$username, [string]$username1, ) $Outlook = New-Object -ComObject Outlook.Application $Mail1 = $Outlook.CreateItem(0) $Mail2 = $Outlook.CreateItem(0) $Mail1.To = "$username1" $Mail2.To = "$username" $Mail1.Subject = "SUBJECT" $Mail1.Body = "--content--" $Mail2.Subject = "SUBJECT" $Mail2.Body = "--content--" $mail1.VotingOptions = "Approve;Reject" $Mail1.Send() $Mail2.Send() 

To clear recipient addresses, you can add text to letters indicating that this message is also sent to $username .

+2
source

All Articles