我想通过VBA代码自动将我的所有电子邮件发送到我的个人电子邮件地址,该代码工作正常。但是当我去发送物品时,BCC字段对我来说是可见的,我也希望将它隐藏起来,以便即使它对我来说也不可见。
任何人都可以通过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 = "privateemail@gmail.com"
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 :(得分:0)
您可以在已发送邮件文件夹中使用ItemAdd代码,以便在项目转到该文件夹时删除密件抄送。
此处描述了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格式。如果您想保留其他密件抄送地址,您可能还想指定地址。