Help on Outlook 2010 VBA not working

Hi,

We have a Outlook VBA that EE helped us some time ago where it places BCC email automatically when creating, replying and forwarding an email.  Some time back the computer failed and the VBAs were not restored to the Outlook.  We  just finish restoring the VBA to the ThisOutlookSession but it doesn't work and can't find the documentation.  We want to every time we create, reply or forward and email, the BCC field is filed automatically based on this script.  Please advice what  are we missing (below the VBA).

Private WithEvents m_Inspectors As Outlook.Inspectors
Private Sub Application_Startup()
  Set m_Inspectors = Application.Inspectors
End Sub
Private Sub m_Inspectors_NewInspector(ByVal Inspector As Inspector)
Dim objRecip As Recipient
Dim strMsg As String
Dim strBCC As String
    If TypeName(Inspector.CurrentItem) = "MailItem" Then
        If Inspector.CurrentItem.EntryID = "" Then
        ' #### USER OPTIONS ####
        ' address for Bcc -- must be SMTP address or resolvable
        ' to a name in the address book
            strBCC = "someone@somewhere.dom"            
            Set objRecip = Inspector.CurrentItem.Recipients.Add(strBCC)
            objRecip.Type = olBCC
            If Not objRecip.Resolve Then
                strMsg = "Could not resolve the Bcc recipient."
                MsgBox strMsg, vbInformation, "Could Not Resolve Bcc Recipient"
            End If
            Set objRecip = Nothing
        End If
    End If
End Sub

Open in new window

rayluvsAsked:
Who is Participating?
 
rayluvsAuthor Commented:
Hi,

No results as if the VBA does't even get there so I went into File >> Option >> Trust >> Trust Center Settings >> Macro Settings

- found that it was selected "notify for digital signed macros"
- I changed it to "enable all macro (not recommended..."

And it worked (I guess it was the macro setting).

Is it ok to leave at  "enable all macro (not recommended..." (the outlook is only used by one person)
0
 
Bill PrewCommented:
Where did you place that VBA code, in a new module, etc?


»bp
0
 
NorieVBA ExpertCommented:
This code should go in the ThisOutlookSession module and you would need to close and restart Outlook for it to work.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
rayluvsAuthor Commented:
That is where I have it (as it says in the commented line) - see pix below:

OutlookVBA
Also, restarted Outlook and also the PC.

This same VBA used to work perfectly some time back.... what am i missing.
0
 
Bill PrewCommented:
I would suggest setting a breakpoint on line 9, and then receiving an email you think should trigger the code.  If it doesn't pop up the VB IDE then it never got to the code.  If it does, then it will be sitting at the breakpoint.  <F8> stepping through the code to see where it may not be executing as you expect.


»bp
0
 
NorieVBA ExpertCommented:
I checked the code using a breakpoint as Bill suggested, and it was definitely triggered when I created a new email.

Have you checked your Trust Center Settings... under File>Options?

If you have Macro Settings set to Disable all macros without notification the code won't work.
0
 
rayluvsAuthor Commented:
Din't thought of that, will do check-point.
0
 
Bill PrewCommented:
Yes, if they don't make a habit of clicking on suspicious attachments on emails, etc, then you should be okay with that setting.


»bp
0
 
rayluvsAuthor Commented:
Thsnx!
0
 
rayluvsAuthor Commented:
Selected my entry as best since that helped run the VB.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.