Stop email sending if a specified distribution list is not in the BCC field.

Hi experts,

We use Outlook 2003 and Win XP Pro.

We use to send an email to our buyers list to inform them when we have new assets for sale. We don't want them to see each other in this list (modified weekly) and that's why we put the distribution list within BCC field. Usually, this sending is done by our secretary.

Unfortunately, it happened that she put the distribution list in the CC field rather than in the BCC field. For her, I created a draft where I put the distribution list in the BCC field. I asked her to use this draft as a template by copying it before she send the new copy correctly. It's not mistake-proof as she made a mistake again today (don't ask me how please).

How can I force the email to be sent using BBC when this distribution list is the recipient in any field?

I know Excel VBA and use it oftenly, but I'm not good with Outlook VBA (never used it up to now) so your explanations will need to be very clear.

Thanks,
gahuteAsked:
Who is Participating?
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.

David LeeCommented:
Hi, gahute.

I can make the check with a bit of VBA, but that creates another problem.  Outlook security prohibits VBA from accessing any field that contains an address.  When a script tries to access a field containing an address Outlook pop up a dialog-box warning the user that an application is accessing their mailbox and asking for their permission to allow it to continue.  Outlook security cannto be turned off, but there are ways to work around it.

1.  Sign the code.  Here's a link to instructions on doing that: http://msdn.microsoft.com/en-us/library/aa155754(office.10).aspx
2.  Use ClickYes (http://www.contextmagic.com/express-clickyes/), a small utility that'll click the Yes button for you.  It creates a security hole though, since a virus could start sending messages and ClickYes would click the Yes button for it too.  
3.  Use Redemption (http://www.dimastr.com), a COM library that enables code to safely bypass Outlook security.

If this isn't a problem, then I can provide the code and instructions on how to use it.
0
gahuteAuthor Commented:
Hi BlueDevilFan,

Your first proposition looks the best one but I have a question before I check it in details. On your link, it says "Outlook 2000", is it also ok for "Outlook 2003"? If yes, I'll check that in details and get back to you.

Thanks,
0
David LeeCommented:
Yes, it's for Outlook 2003 also.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

gahuteAuthor Commented:
Hi BlueDevilFan,

Sorry for the delay, I was on holidays. But I will check it in the next days. I'll try to sign the code and get back to you.

Thanks,
0
gahuteAuthor Commented:
BlueDevilFan,

Your first point looks correct. I signed my project. Now what are the next steps?

Thanks,
0
David LeeCommented:
This code should do it.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools > Macro > Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.
14. Sign the code
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkRcp As Outlook.Recipient
    If Item.Class = olMail Then
        For Each olkRcp In Item.Recipients
            'Edit the list name on the next line'
            If olkRcp.Name = "My List Name" Then
                If olkRcp.Type <> olBCC Then
                    Cancel = True
                    Exit For
                End If
            End If
        Next
    End If
End Sub

Open in new window

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
gahuteAuthor Commented:
Hello BlueDevilFan,

Since this program will be installed on our secretary's computer, I'd prefer to set security level (step #10) to "High" because I don't want her to choose if macros should be executed or not on its computer...

Is it correct to do so?

Éric
0
David LeeCommented:
I'm not sure that the code will run.  I think High disables all code.  No harm in trying it out and seeing what happens.
0
gahuteAuthor Commented:
BlueDevilFan,

It seems to work fine with security level set to high.

Would it be possible to change the code in order to verify that the email is sent to any distribution list rather than to a specific named distribution list?
I mean change "if sent to a specific list" ==> "if sent to any distribution list"...

Thanks a lot,
0
David LeeCommented:
I've modified the code (below) to check for any distribution list.  Replace the code above with the version below.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkRcp As Outlook.Recipient
    If Item.Class = olMail Then
        For Each olkRcp In Item.Recipients
            'Edit the list name on the next line'
            If olkRcp.AddressEntry.AddressEntryUserType = olExchangeDistributionListAddressEntry Or olOutlookDistributionListAddressEntry Then
                Cancel = True
                Exit For
            End If
        Next
    End If
End Sub

Open in new window

0
gahuteAuthor Commented:
Thank you very much BlueDevilFan!

Your solution is exactly what I was looking for. It was clear and easy to understand.

Thanks again!
0
David LeeCommented:
You're welcome.  Glad I could help.
0
sullisnyc44Commented:
I would actually like to implement this in Outlook 2007 for all email sent FROM a particular account. Can I do that? Or at least prompt the user?
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.