?
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
Medium Priority
?
76 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
Alexei Kuznetsov (Outlook MVP) earned 2000 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 14

Expert Comment

by:Alexei Kuznetsov (Outlook MVP)
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

765 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