1

After I reinstalled Outlook 2010, my code to BBC automatically doesn't work anymore! Any ideas to make it work again? Many thanks!

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
Dim myOlApp As Outlook.Application
Dim myOlMsg As Outlook.MailItem

On Error Resume Next

' create outlook objects for referance
Set myOlApp = CreateObject("Outlook.Application")
Set myMsg = myOlApp.ActiveInspector.CurrentItem

' address to BCC
strBcc = "[email protected]"

' if the sender address is the support account utilize bcc
If myMsg.SenderEmailAddress = "[email protected]" Then
  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

FYI, I put this VBA script in "ThisOutlookSession" object my vba location FYI again, I've done with the "send me a copy of every mail I send" with some tips in "Rule and Alert", but still want to know why this code doesnt work.

4
  • where are you pasting this code? did you compile it? put a simple messagebox saying something in code to see if your code is being executed in first place. Jun 19, 2012 at 4:38
  • 1
    Did you restart Outlook and digitally sign your project?
    – JimmyPena
    Jun 19, 2012 at 20:37
  • Sorry, I don't know how to "digitally sign your project", please show me a guide . Thanks!
    – Luke
    Jun 20, 2012 at 2:25
  • Check your Trust Center settings, the reinstall may have reset them to factory settings. Jul 7, 2022 at 16:41

1 Answer 1

1

Check Macro Security level http://www.slipstick.com/outlook-developer/how-to-use-outlooks-vba-editor/ Outlook 2010: File, Options, Trust Center, Macros.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .