Assign folder permissions in Outlook 2010 with VBA - vba

Morning,
I'm trying to identify a way of updating permissions to an Outlook 2010 inbox and all of its subfolders with VBA.
We have an account with a large amount of subfolders that several new users need access to. To assign each of these manually will take hours and I'm looking for an automated process, as this will be a reoccuring task.
Due to administrator restrictions I'm only able to use native VBA.
Is this possible, or am I doomed to hours of mundane repetitive pointing and clicking?
Many thanks
Pete

The Outlook object model (used in VBA) doesn't provide anything for changing folder permissions.
You can use a low-level API - Extended MAPI for accessing permissions. Folder level permissions are stored in folders. You need to get the PR_ACL_TABLE property value using the IMAPIFolder::OpenProperty method. Or you may consider using any third-party wrappers around that API that simplify the dev process. See Changes in Outlook 2010 folder permissions not shown in Active Directory for more information.

Since you are using VBA, Extended MAPI is out of the question (you'd need C++ or Delphi).
If using Redemption is an option (I am its author), you can use its RDOACL object (returned by RDOFolder.ACL property) to manage any Exchange folder permissions:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderCalendar)
'make sure we get back an Exchange user
set AddressEntry = Session.AddressBook.GAL.ResolveName("Pete")
set ACE = Folder.ACL.Add(AddressEntry)
ACE.Rights = ROLE_PUBLISH_EDITOR

Related

How to apply Azure Information Protection labels to an Outlook email using Access VBA?

I have a VBA function in our MS Access database that generates Outlook emails and sends them from a shared inbox.
Our company uses Azure Information Protection to protect documents. A label needs to be applied to each email before it is sent (e.g. Public, Business Sensitive, Internal).
Rather than having the user click the label 25 times as it pops up for each email, I am trying to apply it programmatically.
I get error code (-1248837627).
My solution was to grab the labels GUID and then apply it to the email as below. I came across other solutions such as using SendKeys but I prefer it to be a last resort.
With olMail
.To = olSendTo
.Subject = olSubject
.PermissionTemplateGuid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
.Permission = olPermissionTemplate
'And so on, the email function works great until the above two lines are added
Am I applying the .Permissions or .PermissionTemplateGUID improperly?
I have seen a similar approach to apply labels to Excel documents (grabbing and setting the guid).
The code you posted is used to specify Information Rights Management (IRM) permissions. Azure Information Protection is another story.
You need to add a user property in the following format:
"MSIP_Label_" & guid_internal_use_only & "_Enabled"
But I'd suggest exploring internals of Outlook mail items using MFCMAPI or OutlookSpy to find the exact solution. Try to set it manually then explore internals using these tools.

Copy one account client-side rule to all client-side rules

Is there any way to copy the outlook rule of one account to another account using VBA code. I have researched on the internet I have not found anything related to my question, Pls help me. I will be very thankful to you.
The Outlook object model doesn't provide any property or method for that. However, you can use a low-level functionality to access rules. Use the PropertyAccessor object to get and set item-level properties that are not explicitly exposed in the Outlook object model, or properties for the following non-item objects: AddressEntry, AddressList, Attachment, ExchangeDistributionList, ExchangeUser, Folder, Recipient, and Store.
Rules are kept as hidden items in your Inbox folder (see the associated content which is not visible in the Outlook UI). You may use MFCMAPI or OutlookSpy for exploring the hidden content.

Outlook Shared Inbox Macros

I will try to be as clear as possible. There are 5 people on my team. We each have our own personal outlook email accounts. Our team leader is ALSO the owner of an account that we all have access to (call it "SharedAccount#xx.com"). I have macros that I want to put into that shared email account, that will listen to the inbox of that email account and do stuff with the incoming messages. Since I am not the owner of that account, I wrote Macros in my personal email and for the NameSpace business I used the following code (note, again, this is in MY personal email ThisOutlookSession):
Dim objNS As Outlook.NameSpace
Set objNS = olApp.GetNamespace("MAPI")
Dim rec As recipient
Set rec = objNS.CreateRecipient("SharedAccount#xx.com")
rec.Resolve
Set inbox = objNS.GetSharedDefaultFolder(rec, olFolderInbox)
Am I doing this wrong? Do I instead need to put this code into the macros on the "Shared#xx.com" account profile? I know the macros work in regards to the listeners and all that, so the problem has something to do with NameSpaces I feel like. I would really, really appreciate any help I can get. Thank you!
Each user normally accesses their own VbaProject.otm file. See VbaProject.OTM deployment for a description of "a parameter altvba that allows to specify another path to run the OTM file from".
If that is not feasible you could use one of the methods described here. http://www.outlookcode.com/article.aspx?id=28 also referenced in the above.
"The least intrusive technique is to use the File | Export command in the Outlook VBA environment to export modules as .bas, .cls, and .frm files."
"The brute force approach is to copy this file from the machine where the macros were written to other users' machines, replacing any existing VbaProject.otm file." (Not very nice.)
It is easiest for me to send a mail, then paste the text into their editor.

Persisting VBA/VBScript macro settings

I've created an Outlook (2010) VBScript macro that has some user-configurable settings. I've googled and checked the likely resources and can't figure out a good way to persist them. I'm currently storing them in the body of a mail item! It don't get much kludgier than that!
Should I use the Windows registry? An ini file? Or??? And whether registry, file, or???, what key/folder/??? would I use?
Just before hitting 'Post' on this I tried one more google search and hit on this: http://www.jkp-ads.com/articles/DistributeMacro08.asp.
The gist I took away was, ini file or registry are both kosher. One nice thing about VBA's use of the registry is it automatically puts "app" data in the approved place, just need to give your "app" a key. Since my data is just a big string with parsing code already in place, I used strData = GetSetting(strAppKey, strSection, strLeafKey) and SaveSetting(strAppKey, strSection, strLeafKey, strData) and voila, all is good.
The standard Outlook way of storing settings, especially if they relate to a particular mailbox/store and can be accessed from multiple machines connected to the same mailbox, is to use a hidden message stored in one of the well known folders, such as the Inbox.
The hidden MAPI messages can be accessed using MAPIFolder.GetStorage: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getstorage.aspx

Saving program shared data in Exchange Public Folder

I have a question reffering to Public Folders on Exchange Server.
I have an application (Outlook Com Addin) that need to share settings amonge every Exchange User that have access to Public Folders.
I was thinking about storing settings in MAPI assotiated message (hidden MAPI message). Wirting\Reading data from this message works fine, but I don't have good place to save this item.
I am looking from some sort of global folder or root folder that every user have. I tried All Public Folders folder, but noone can store any item there. I was also thinking about NON_IPM_SUBTREE but I am not sure which folder can be used to write there something.
Maybe someone faced this problem already and have some thoughts about this it?
And to make things clear. I am using Extended MAPI, but if you know any solution that involves Outlook API, I would be interested in that too.
Best regards,
There are no predefined PF folders. Most installations will have "Outlook Security Settings", but that is about it.
There is also a set of hidden folders where Outlook stores f/b info.
Keep in mind that PF is optional as of Exchange 2007. Exchange 2010 does not install PF store by default.