I have found several topics about similar issue but I can not find any documentation for this and none of those correspond my issue directly.
$ol = New-Object -comObject Outlook.Application
$newmail = $ol.CreateItem(0)
$newmail.Recipients.Add($Manager.EmailAddress)
$newmail.Recipients.Add($User.EmailAddress)
The only thing I need is to make the 2nd receipient ($User.EmailAddress) in CC field instead "to" field in Outlook's draft. How can I accomplish it? Moreover is there any documentation about those functions?
Cheers!
Since the default recipient type is olTo
, you need to give the second recipient a different type, namely olCC
:
$ol = New-Object -comObject Outlook.Application
$newmail = $ol.CreateItem(0)
# the manager goes in the 'To'
$newmail.Recipients.Add($Manager.EmailAddress)
# this one should go in the 'CC'
$recip = $newmail.Recipients.Add($User.EmailAddress)
$recip.Type = 2
for Outlook Recipient Type enum look here: https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/olmailrecipienttype-enumeration-outlook