2016-05-03 67 views
0

我想通過VBA代碼自動將我的所有電子郵件都發送到我的個人電子郵件地址。但是當我去發送郵件時,BCC字段對我來說是可見的,我想將它從自己隱藏起來,這樣即使它對我來說也是不可見的。通過VBA自動密件抄送,但密件抄送字段隱藏

任何人都可以請幫助這與VBA代碼。由於

目前我使用下面的代碼:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) 
Dim objRecip As Recipient 
Dim strMsg As String 
Dim res As Integer 
Dim strBcc As String 
On Error Resume Next 

' #### USER OPTIONS #### 
' address for Bcc -- must be SMTP address or resolvable 
' to a name in the address book 
strBcc = "[email protected]" 

Set objRecip = Item.Recipients.Add(strBcc) 
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

讓我們看看你的代碼,請 – duDE

+0

感謝duDE編輯。 – Faraz

+0

嗨 我在Outlook 2013中嘗試過這種解決方案,但它不工作,請任何建議... – Faraz

回答

0

您可以在發送郵件使用ItemAdd代碼文件夾,當一個項目進入該文件夾刪除BCC。

ItemAdd在這裏描述了默認的收件箱文件夾。 https://stackoverflow.com/a/11267757/1571407

這表明了這個想法。

Option Explicit 

Private Sub removeBcc() 

Dim objItem As Object 
Dim objRecip As recipient 
Dim i As Long 

On Error Resume Next 
Set objItem = ActiveInspector.currentItem 
On Error GoTo 0 

If Not objItem Is Nothing Then 

    If objItem.Class = olMail Then 

     For i = objItem.Recipients.count To 1 Step -1 
      Set objRecip = objItem.Recipients(i) 
      If objRecip.Type = olBCC Then 
       objItem.Recipients.Remove (i) 
      End If 
     Next 

    End If 

End If 

'objItem.Save 

ExitRoutine: 
    Set objItem = Nothing 

End Sub 

根據需要修改ItemAdd格式。如果您想保留其他密件抄送地址,您可能還想指定地址。

相關問題