规则仅发送包含BCC地址的电子邮件

时间:2014-12-03 21:47:26

标签: outlook-vba outlook-2010

我发现了一段代码,它会让我自动发送每封电子邮件的BCC。

我想要做的是:当收到主题行中的特定内容时,电子邮件将在BCC字段中使用“email@email.com”自动转发,而在“收件人”行中没有人。

Public Sub BCC(Item As Outlook.MailItem)

Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim BCC_ADDR As String
On Error Resume Next

BCC_ADDR = "email@email.com"

Set objRecip = Item.Recipients.Add(BCC_ADDR)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
    strMsg = "Could not resolve the Bcc recipient. " & _
    "Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Could Not Resolve Bcc Recipient")
    If res = vbNo Then
        Cancel = True
    End If
End If

Set objRecip = Nothing
End Sub

1 个答案:

答案 0 :(得分:0)

您需要使用Forward方法对项执行Forward操作,并将生成的副本作为MailItem对象返回。然后,您可以使用Send方法提交项目以供进一步处理。例如:

`Public Sub BCC(Item As Outlook.MailItem)
     Dim objRecip As Recipient
     Dim strMsg As String
     Dim res As Integer
     Dim BCC_ADDR As String
     Dim forward as MailItem
     On Error Resume Next          
     BCC_ADDR = "email@email.com"
     Set forward = Item.Forward
     Set objRecip = forward.Recipients.Add(BCC_ADDR)
     objRecip.Type = olBCC
     If Not objRecip.Resolve Then
         strMsg = "Could not resolve the Bcc recipient. " & _
        "Do you want still to send the message?"
        res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
        "Could Not Resolve Bcc Recipient")
        If res = vbNo Then
             Cancel = True        
        End If
     Else
        foward.Send
     End If
     Set objRecip = Nothing
End Sub`