Solved

VBA code to set Sensitvity Tag to Private based on a certain recipient in the recipient lines in Outlook

Posted on 2016-10-20
4
34 Views
Last Modified: 2016-10-30
I am trying to figure out if there is a way when one of my users creates an email to a certain email group, say Friends, that the new email message will automatically set the Sensitivity Tag to Private and display a message that it was set and not allow it to be changed?  Or another possible approach would be that when the user tries to send the email with that group in one of the recipient lines it will check to see if Sensitivity Tag is set to Private and if not, it would pop up a message telling them to set it and not let the user send the email until that tag is set.  The message would continuously pop up when the user tries to send until the tag is set.

I would imagine this can be done, but I haven't coded VBA in a long time and never for Outlook.
0
Comment
Question by:TPBPIT
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Alexei Kuznetsov earned 500 total points
ID: 41853541
That's pretty easy. Something like this:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Sensitivity <> olPrivate Then
        For Each Recip In Item.Recipients
            If Recip.Address = "friends@domain.com" Then
                MsgBox "Not Private!"
                Cancel = True
                Exit For
            End If
        Next
    End If
End Sub

Open in new window

If you want, you can check Recip.Name instead of address. You may also want to set Item.Sensitivity to olPrivate automatically instead of Cancelling the message.
1
 

Author Comment

by:TPBPIT
ID: 41853983
Is there a way to OR the recip.address to allow for a couple of recipients to be check?  Say I wanted to look for Friends and Enemies.

And if you do Recip.Name instead, and you wanted to use group names from the global address list, who would you enter the name?  Just as it reads in the GAL?
0
 
LVL 13

Expert Comment

by:Alexei Kuznetsov
ID: 41854003
Yes, sure. Like this in line 4:
If Recip.Name = "Friends" Or Recip.Name = "Enemies" Then

Open in new window

0
 

Author Closing Comment

by:TPBPIT
ID: 41866030
Thanks for the help with this.  It worked perfectly.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now