自动添加CC在Outlook中的新消息中使用VBA不会出现?

时间:2013-06-11 05:21:17

标签: vba outlook outlook-vba

当我点击新的电子邮件outlook时,自动cc电子邮件不会出现在cc文本区域的VBA代码中请帮我这样做我已经在Application_ItemSend事件中使用VBA添加CC但是它出现在消息发送后我想显示当用户单击outlook功能区中的新消息时,启动CC。

2 个答案:

答案 0 :(得分:0)

我认为这是您希望发布代码以获得更清晰的内容。

    strcc = "xxx@yyy.com"
    Dim objRecip As Recipient
    Set objRecip = Item.Recipients.Add(strcc)
    objRecip.Type = olCC
        If Not objRecip.Resolve Then
        strMsg = "Could not resolve the cc recipient. " & _
        "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
        "Could Not Resolve cc Recipient")
            If res = vbNo Then
            Cancel = True
            End If
        End If
    Set objRecip = Nothing`

答案 1 :(得分:0)

请参阅此处的NewInspector事件示例

Fire an Outlook 2003 macro when the user creates a new blank message

Public WithEvents myOlInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Initialize_handler
End Sub

Public Sub Initialize_handler()
    Set myOlInspectors = Application.Inspectors
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
    Dim msg As Outlook.MailItem
    If Inspector.CurrentItem.Class = olMail Then
        Set msg = Inspector.CurrentItem

        If msg.Size = 0 Then
            MsgBox "New message"
        End If
    End If
End Sub