outlook vba将收件人添加到外发电子邮件中

时间:2014-06-17 19:05:03

标签: vba email outlook outlook-vba

我需要在每个新电子邮件草稿的CC字段中添加特定的电子邮件地址。地址需要显示在CC字段中,以便在需要时将其删除。我怎么能在VBA中这样做?现有代码会提示添加人员(如果他们尚未进行CC),这是每次发送电子邮件时不必要的额外点击。

请帮助,谢谢!!

1 个答案:

答案 0 :(得分:3)

陷阱Inspectors.NewInspector事件,使用Inspector.CurrentItem检索当前项目,致电MailItem.Recipients.Add

Public WithEvents oInspectors As Outlook.Inspectors

Private Sub Application_Startup()
  Set oInspectors = Application.Inspectors
End Sub

Public Sub oInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
  Dim msg As Object
  Set msg = Inspector.CurrentItem
  If (msg.Class = 43) And (Not msg.Sent) Then
    Dim recip
    Set recip = msg.Recipients.Add("user@company.com")
    recip.Type = olCC
    recip.Resolve
  End If
End Sub