使用powershell -comobject outlook.application添加电子邮件生成CC

时间:2018-07-12 13:17:20

标签: powershell email outlook cc

我找到了一些与类似问题有关的主题,但是我找不到与此相关的任何文档,这些文档都没有直接对应我的问题。

$ol = New-Object -comObject Outlook.Application
$newmail = $ol.CreateItem(0) 
$newmail.Recipients.Add($Manager.EmailAddress)
$newmail.Recipients.Add($User.EmailAddress) 

我唯一需要做的就是在CC字段中使第二个收件人($ User.EmailAddress)成为Outlook草案中的“收件人”字段。我该怎么做?此外,有关于这些功能的任何文档吗?

干杯!

1 个答案:

答案 0 :(得分:2)

由于默认收件人类型为olTo,因此您需要为第二个收件人指定其他类型,即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

对于Outlook收件人类型枚举,请看这里:https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/olmailrecipienttype-enumeration-outlook