VBA code not starting on some Outlook 2003 clients, does on others.

  • Thread starter Thread starter Jason.Congdon
  • Start date Start date
J

Jason.Congdon

I've got some code to BCC a recipient based on the who the message is
being sent to. It works great on about half of the computers I try it
on, and about half doesn't run through the code at all.
The clients are all Outlook2003, on WindowsXP.

The code is in ThisOutlookSession, but it simply ignores the code on
several computers. Does someone know of a setting or registry setting
that is causing the code to be ignored?

Thanks
 
This is the code that I am trying to run

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim objMe As Recipient
If test(Item) Then
Set objMe = Item.Recipients.Add("insert bcc recipient here")
objMe.Type = olBCC
objMe.Resolve
Set objMe = Nothing
End If
End Sub

Function test(objMail As Outlook.MailItem) As Boolean
Dim objRecip As Outlook.Recipient
For Each objRecip In objMail.Recipients
'when sending email to X carbon copy Y...Enter X's email address here :
If objRecip = "recipient address here" Then
test = True
End If
Next
End Function

It runs fine on some, doesn't launch on others. Going to see if it is
just the ItemSend event or vba code in general
 
Am 16 May 2006 06:53:48 -0700 schrieb (e-mail address removed):

Did you check the security setting under Tools/Macros/Security? It must be
medium or low, or you´d have to certificate the project.
 
Yes it was the macro security. This is one of the first things I
checked but I ruled it out quickly as I would set it to high, and it
would still work. What wasn't clear was that Outlook actually requires
a restart for that change to take effect. I tried again on mine,
setting it to high macro security, restarting Outlook and sure enough
my code wouldn't run.

Would have been nice if changing that setting gave an indication that I
need to restart Outlook for the setting to take effect, or at the very
least an error in Outlook similar to Excel when your macro secuirty is
too high for your scripts.

Thanks.
 
Back
Top