Make Outlook asking if you want to Send-BCC a sent Message

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim ans
ans = MsgBox("Send this message bcc to xyz?", vbYesNoCancel)
If ans = vbCancel Then Cancel = True

If ans = vbYes Then
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 = "user@domain.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 If

End Sub

another version:

Public Sub SetBCC2()

Dim objItem As Outlook.MailItem
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
'On Error Resume Next

Set objItem = ActiveExplorer.Application.ActiveInspector.CurrentItem

objItem.Recipients.ResolveAll

For Each Recipient In objItem.Recipients
If (Recipient.Type = olBCC) Then
If Recipient = "sent@profiline-berufsmode.ch" Then
Already = True
End If
End If
Next Recipient

If Already = False Then
' MsgBox ("noch nicht drauf, also adde ich jetzt")
strBcc = "sent@tastaturkind.ch"
Set objRecip = objItem.Recipients.Add(strBcc)
objRecip.Type = olBCC
objRecip.Resolve
Set objRecip = Nothing
End If

End Sub

Dieser Eintrag wurde veröffentlicht in Allgemein von admin. Setze ein Lesezeichen zum Permalink.