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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Where did you place that VBA code, in a new module, etc?


»bp
0
NorieAnalyst Assistant Commented:
This code should go in the ThisOutlookSession module and you would need to close and restart Outlook for it to work.
0
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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Bill PrewIT / Software Engineering ConsultantCommented:
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
NorieAnalyst Assistant Commented:
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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.