A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Routine for setting de permissions for all underlaying folders



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 3rd 06, 03:28 PM posted to microsoft.public.outlook.program_vba
Guus
external usenet poster
 
Posts: 2
Default Routine for setting de permissions for all underlaying folders

Hello,
First excuse me if my English language is not perfect.

I have made in my Outlook a tree-structure like on my PC, that means there
are a lot of folders in my Outlook.

In a lot of these folders there is the permission set for e.g. Anonymous.

WHAT I WANT IS:
- Create an VB-script or Macro that:
a. sets the property Permission for Name= Default to Level= None
sets the property Permission for Name= John S to Level= Folder
Visible
b. Repeats sentence for all the folders which are created under the
current folder.

For example I give you a part of my folders in Outlook:
- INBOX
- INBOX Educ
- INBOX OI
- INBOX UNI
- ASSESSMENT
- BLOCK
- SKILLS
- PROGRESS

So, if the current folder is 'INBOX' I want that the script ends after
'INBOX UNI'

I hope someone can help me to create a macro or script.
Thank you in advance,
Guus

  #2  
Old October 3rd 06, 05:00 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Routine for setting de permissions for all underlaying folders

Unfortunately, it's not that easy. You cannot do this with Outlook VBA, you
need to use CDO 1.21. You also need ACL.dll, which is not usually present on
most computers. It is part of the Platform SDK and must be compiled and
distributed with your solution. However, you can download it via a link in
this blog:

MS Exchange Blog : Setting calendar permissions centrally...:
http://hellomate.typepad.com/exchang...g_calenda.html

If you'd like more awesome sample code on using the ACL component, there's
more he

How To Use ACL Object and CDO (1.21) to List Folder Permissions for a MAPI
Folder:
http://support.microsoft.com/default...b;en-us;240911

Here's an example as well that you can mine to do what you need to do:

Private Sub AddUserToFolder()
On Error GoTo ErrorHandler

Const CdoDefaultFolderCalendar = 0
Const CdoDefaultFolderInbox = 1
Const CdoDefaultFolderOutbox = 2
Const CdoDefaultFolderSentItems = 3
Const CdoDefaultFolderDeletedItems = 4
Const CdoDefaultFolderContacts = 5
Const CdoDefaultFolderJournal = 6
Const CdoDefaultFolderNotes = 7
Const CdoDefaultFolderTasks = 8
Const CdoDefaultFolderTotal = 9


Const ROLE_OWNER = &H5E3
Const ROLE_PUBLISH_EDITOR = &H4E3
Const ROLE_EDITOR = &H463
Const ROLE_PUBLISH_AUTHOR = &H49B
Const ROLE_AUTHOR = &H41B
Const ROLE_NONEDITING_AUTHOR = &H413
Const ROLE_REVIEWER = &H401
Const ROLE_CONTRIBUTOR = &H402
Const ROLE_NONE = &H400


Dim strProfile As String
Dim oSession As Object 'MAPI.Session
Dim oAddrBook As Object 'MAPI.AddressList
Dim oDelegate As Object 'MAPI.AddressEntry
Dim oInbox As Object 'MAPI.Folder
Dim oMailbox As Object 'MAPI.InfoStore
Dim oACLObject As ACLObject
Dim oACEs As IACEs
Dim oNewAce As Object


'Change this to the display name of the user you want to give delegate
access.
Const UserA = "Joe Blow" 'must use full name to retrieve an AddressEntry
by name
'from the AddressEntries.Item collection
'--------------------------------------------------


'Change this to the display name of the user whose
'folder you want to give UserA access to.
Const UserB = "Jane Doe"


'Change server_name to the name of your Exchange server.
strProfile = "servername" & vbLf & UserB


' Create a new MAPI session and log on.
Set oSession = CreateObject("MAPI.Session")
oSession.Logon , , False, True, , True, strProfile


' Create a MAPI object for UserA
Set oAddrBook = oSession.AddressLists("Global Address List")


'This calls the Outlook Object Model guard
Set oDelegate = oAddrBook.AddressEntries.Item(UserA)
'If the user clicks no, this error will be generated:
'Error: "[Collaboration Data Objects - [E_ACCESSDENIED(80070005)]]"
'Number: -2147024891


' Get the permission list on UserB's inbox


MsgBox "Adding " & UserA & " to the Inbox permissions for " & UserB & "
with Reviewer settings."


Set oInbox = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oACLObject = CreateObject("MSExchange.ACLObject")
oACLObject.CDOItem = oInbox
Set oACEs = oACLObject.ACEs


' Add UserA to the permission list and save the result


Set oNewAce = CreateObject("MSExchange.ACE")


oNewAce.ID = oDelegate.ID
oNewAce.Rights = ROLE_REVIEWER
MsgBox oACEs.Count
oACEs.Add oNewAce
oACLObject.Update
MsgBox oACEs.Count
oSession.Logoff


' Indicate the process is finished.
MsgBox "Completed adding " & UserA & " to Inbox permissions for " &
UserB & "."


ErrorHandler:
MsgBox "Error " & Err.Number & vbCr & Err.Description, vbOKOnly
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Guus" wrote:

Hello,
First excuse me if my English language is not perfect.

I have made in my Outlook a tree-structure like on my PC, that means there
are a lot of folders in my Outlook.

In a lot of these folders there is the permission set for e.g. Anonymous.

WHAT I WANT IS:
- Create an VB-script or Macro that:
a. sets the property Permission for Name= Default to Level= None
sets the property Permission for Name= John S to Level= Folder
Visible
b. Repeats sentence for all the folders which are created under the
current folder.

For example I give you a part of my folders in Outlook:
- INBOX
- INBOX Educ
- INBOX OI
- INBOX UNI
- ASSESSMENT
- BLOCK
- SKILLS
- PROGRESS

So, if the current folder is 'INBOX' I want that the script ends after
'INBOX UNI'

I hope someone can help me to create a macro or script.
Thank you in advance,
Guus

  #3  
Old October 4th 06, 01:54 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Routine for setting de permissions for all underlaying folders

plugYou can also set permissions using Redemption through the
RDOFolder.ACL collection -
http://www.dimastr.com/redemption/rdo/RDOACL.htm/plug

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Eric Legault [MVP - Outlook]" wrote in
message news
Unfortunately, it's not that easy. You cannot do this with Outlook VBA,
you
need to use CDO 1.21. You also need ACL.dll, which is not usually present
on
most computers. It is part of the Platform SDK and must be compiled and
distributed with your solution. However, you can download it via a link
in
this blog:

MS Exchange Blog : Setting calendar permissions centrally...:
http://hellomate.typepad.com/exchang...g_calenda.html

If you'd like more awesome sample code on using the ACL component, there's
more he

How To Use ACL Object and CDO (1.21) to List Folder Permissions for a MAPI
Folder:
http://support.microsoft.com/default...b;en-us;240911

Here's an example as well that you can mine to do what you need to do:

Private Sub AddUserToFolder()
On Error GoTo ErrorHandler

Const CdoDefaultFolderCalendar = 0
Const CdoDefaultFolderInbox = 1
Const CdoDefaultFolderOutbox = 2
Const CdoDefaultFolderSentItems = 3
Const CdoDefaultFolderDeletedItems = 4
Const CdoDefaultFolderContacts = 5
Const CdoDefaultFolderJournal = 6
Const CdoDefaultFolderNotes = 7
Const CdoDefaultFolderTasks = 8
Const CdoDefaultFolderTotal = 9


Const ROLE_OWNER = &H5E3
Const ROLE_PUBLISH_EDITOR = &H4E3
Const ROLE_EDITOR = &H463
Const ROLE_PUBLISH_AUTHOR = &H49B
Const ROLE_AUTHOR = &H41B
Const ROLE_NONEDITING_AUTHOR = &H413
Const ROLE_REVIEWER = &H401
Const ROLE_CONTRIBUTOR = &H402
Const ROLE_NONE = &H400


Dim strProfile As String
Dim oSession As Object 'MAPI.Session
Dim oAddrBook As Object 'MAPI.AddressList
Dim oDelegate As Object 'MAPI.AddressEntry
Dim oInbox As Object 'MAPI.Folder
Dim oMailbox As Object 'MAPI.InfoStore
Dim oACLObject As ACLObject
Dim oACEs As IACEs
Dim oNewAce As Object


'Change this to the display name of the user you want to give delegate
access.
Const UserA = "Joe Blow" 'must use full name to retrieve an
AddressEntry
by name
'from the AddressEntries.Item collection
'--------------------------------------------------


'Change this to the display name of the user whose
'folder you want to give UserA access to.
Const UserB = "Jane Doe"


'Change server_name to the name of your Exchange server.
strProfile = "servername" & vbLf & UserB


' Create a new MAPI session and log on.
Set oSession = CreateObject("MAPI.Session")
oSession.Logon , , False, True, , True, strProfile


' Create a MAPI object for UserA
Set oAddrBook = oSession.AddressLists("Global Address List")


'This calls the Outlook Object Model guard
Set oDelegate = oAddrBook.AddressEntries.Item(UserA)
'If the user clicks no, this error will be generated:
'Error: "[Collaboration Data Objects - [E_ACCESSDENIED(80070005)]]"
'Number: -2147024891


' Get the permission list on UserB's inbox


MsgBox "Adding " & UserA & " to the Inbox permissions for " & UserB & "
with Reviewer settings."


Set oInbox = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oACLObject = CreateObject("MSExchange.ACLObject")
oACLObject.CDOItem = oInbox
Set oACEs = oACLObject.ACEs


' Add UserA to the permission list and save the result


Set oNewAce = CreateObject("MSExchange.ACE")


oNewAce.ID = oDelegate.ID
oNewAce.Rights = ROLE_REVIEWER
MsgBox oACEs.Count
oACEs.Add oNewAce
oACLObject.Update
MsgBox oACEs.Count
oSession.Logoff


' Indicate the process is finished.
MsgBox "Completed adding " & UserA & " to Inbox permissions for " &
UserB & "."


ErrorHandler:
MsgBox "Error " & Err.Number & vbCr & Err.Description, vbOKOnly
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Guus" wrote:

Hello,
First excuse me if my English language is not perfect.

I have made in my Outlook a tree-structure like on my PC, that means
there
are a lot of folders in my Outlook.

In a lot of these folders there is the permission set for e.g. Anonymous.

WHAT I WANT IS:
- Create an VB-script or Macro that:
a. sets the property Permission for Name= Default to Level= None
sets the property Permission for Name= John S to Level= Folder
Visible
b. Repeats sentence for all the folders which are created under the
current folder.

For example I give you a part of my folders in Outlook:
- INBOX
- INBOX Educ
- INBOX OI
- INBOX UNI
- ASSESSMENT
- BLOCK
- SKILLS
- PROGRESS

So, if the current folder is 'INBOX' I want that the script ends after
'INBOX UNI'

I hope someone can help me to create a macro or script.
Thank you in advance,
Guus



  #4  
Old October 4th 06, 02:38 AM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Routine for setting de permissions for all underlaying folders

endorsement I keep forgetting about all the magical stuff you put into that
thing!

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Dmitry Streblechenko" wrote:

plugYou can also set permissions using Redemption through the
RDOFolder.ACL collection -
http://www.dimastr.com/redemption/rdo/RDOACL.htm/plug

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Eric Legault [MVP - Outlook]" wrote in
message news
Unfortunately, it's not that easy. You cannot do this with Outlook VBA,
you
need to use CDO 1.21. You also need ACL.dll, which is not usually present
on
most computers. It is part of the Platform SDK and must be compiled and
distributed with your solution. However, you can download it via a link
in
this blog:

MS Exchange Blog : Setting calendar permissions centrally...:
http://hellomate.typepad.com/exchang...g_calenda.html

If you'd like more awesome sample code on using the ACL component, there's
more he

How To Use ACL Object and CDO (1.21) to List Folder Permissions for a MAPI
Folder:
http://support.microsoft.com/default...b;en-us;240911

Here's an example as well that you can mine to do what you need to do:

Private Sub AddUserToFolder()
On Error GoTo ErrorHandler

Const CdoDefaultFolderCalendar = 0
Const CdoDefaultFolderInbox = 1
Const CdoDefaultFolderOutbox = 2
Const CdoDefaultFolderSentItems = 3
Const CdoDefaultFolderDeletedItems = 4
Const CdoDefaultFolderContacts = 5
Const CdoDefaultFolderJournal = 6
Const CdoDefaultFolderNotes = 7
Const CdoDefaultFolderTasks = 8
Const CdoDefaultFolderTotal = 9


Const ROLE_OWNER = &H5E3
Const ROLE_PUBLISH_EDITOR = &H4E3
Const ROLE_EDITOR = &H463
Const ROLE_PUBLISH_AUTHOR = &H49B
Const ROLE_AUTHOR = &H41B
Const ROLE_NONEDITING_AUTHOR = &H413
Const ROLE_REVIEWER = &H401
Const ROLE_CONTRIBUTOR = &H402
Const ROLE_NONE = &H400


Dim strProfile As String
Dim oSession As Object 'MAPI.Session
Dim oAddrBook As Object 'MAPI.AddressList
Dim oDelegate As Object 'MAPI.AddressEntry
Dim oInbox As Object 'MAPI.Folder
Dim oMailbox As Object 'MAPI.InfoStore
Dim oACLObject As ACLObject
Dim oACEs As IACEs
Dim oNewAce As Object


'Change this to the display name of the user you want to give delegate
access.
Const UserA = "Joe Blow" 'must use full name to retrieve an
AddressEntry
by name
'from the AddressEntries.Item collection
'--------------------------------------------------


'Change this to the display name of the user whose
'folder you want to give UserA access to.
Const UserB = "Jane Doe"


'Change server_name to the name of your Exchange server.
strProfile = "servername" & vbLf & UserB


' Create a new MAPI session and log on.
Set oSession = CreateObject("MAPI.Session")
oSession.Logon , , False, True, , True, strProfile


' Create a MAPI object for UserA
Set oAddrBook = oSession.AddressLists("Global Address List")


'This calls the Outlook Object Model guard
Set oDelegate = oAddrBook.AddressEntries.Item(UserA)
'If the user clicks no, this error will be generated:
'Error: "[Collaboration Data Objects - [E_ACCESSDENIED(80070005)]]"
'Number: -2147024891


' Get the permission list on UserB's inbox


MsgBox "Adding " & UserA & " to the Inbox permissions for " & UserB & "
with Reviewer settings."


Set oInbox = oSession.GetDefaultFolder(CdoDefaultFolderInbox)
Set oACLObject = CreateObject("MSExchange.ACLObject")
oACLObject.CDOItem = oInbox
Set oACEs = oACLObject.ACEs


' Add UserA to the permission list and save the result


Set oNewAce = CreateObject("MSExchange.ACE")


oNewAce.ID = oDelegate.ID
oNewAce.Rights = ROLE_REVIEWER
MsgBox oACEs.Count
oACEs.Add oNewAce
oACLObject.Update
MsgBox oACEs.Count
oSession.Logoff


' Indicate the process is finished.
MsgBox "Completed adding " & UserA & " to Inbox permissions for " &
UserB & "."


ErrorHandler:
MsgBox "Error " & Err.Number & vbCr & Err.Description, vbOKOnly
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Guus" wrote:

Hello,
First excuse me if my English language is not perfect.

I have made in my Outlook a tree-structure like on my PC, that means
there
are a lot of folders in my Outlook.

In a lot of these folders there is the permission set for e.g. Anonymous.

WHAT I WANT IS:
- Create an VB-script or Macro that:
a. sets the property Permission for Name= Default to Level= None
sets the property Permission for Name= John S to Level= Folder
Visible
b. Repeats sentence for all the folders which are created under the
current folder.

For example I give you a part of my folders in Outlook:
- INBOX
- INBOX Educ
- INBOX OI
- INBOX UNI
- ASSESSMENT
- BLOCK
- SKILLS
- PROGRESS

So, if the current folder is 'INBOX' I want that the script ends after
'INBOX UNI'

I hope someone can help me to create a macro or script.
Thank you in advance,
Guus




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Organizational Froms Library Permissions error, but I have permissions? Trigon Outlook - Using Forms 11 February 1st 07 12:49 AM
Setting Calendar Permissions Centrally Ian C Outlook - Calandaring 3 September 28th 06 04:27 PM
Setting Permissions for Shared Calendars compass Outlook - Calandaring 2 August 21st 06 04:37 PM
Access permissions on folder. Owner cannot grant permissions lmeyer Outlook - Installation 0 June 14th 06 11:06 AM
terminate the routine if outlook is not available fitful_thought Outlook - General Queries 1 April 26th 06 02:01 PM


All times are GMT +1. The time now is 01:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.