2014-12-03 82 views
0

我發現的代碼塊,讓我BCC自動每封電子郵件我送。規則以發送電子郵件的BCC地址只

我想要做的是:當具有特定主題行的東西收到,電子郵件是自動轉發在密件抄送字段,沒人用「[email protected]」到行。

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 protected]" 

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 

回答

0

您需要使用Forward方法,執行一個項目的正向作用並返回結果副本作爲的MailItem對象。然後您可以使用發送方法提交該項目以供進一步處理。例如:

`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 protected]" 
    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` 
相關問題