><(({°>

archives
it happens mostly at night
20 June, 2008
# setting delegates in outlook through vb.net
set the publicDelegates field in AD using dsquery to have something first. In this example, my mail server is "mailserver" and the address to get reviewer rights is all allusers and is a distribution list:

Private Sub SetCalendarPerms()
Dim sMailServ = "mailserver"
Dim oSession As New MAPI.Session()
Dim strMBX = Replace(g_cn, "\", "")
Dim oStore As MAPI.InfoStore
Dim oRootFolder As MAPI.Folder
Dim oFolders As MAPI.Folders
Dim oFolder As MAPI.Folder
Dim oACLs As New ACLObject
Dim oFolderACEs As IACEs
Dim oNewACE As New ACE
Dim oAddrBook As MAPI.AddressList
Dim oDelegate As MAPI.AddressEntries
Dim oAllSDC As MAPI.AddressEntry
Dim i As Integer

Try
oSession.Logon(, , , , , , sMailServ & vbLf & strMBX) '("", "", True, True, 0, True, sMailServ & vbLf & strMBX)
oStore = CType(oSession.GetInfoStore, MAPI.InfoStore)
oRootFolder = CType(oStore.RootFolder, MAPI.Folder)
oFolders = CType(oRootFolder.Folders, MAPI.Folders)
oFolderACEs = CType(oACLs.ACEs, IACEs)
oAddrBook = oSession.AddressLists("Global Address List")
oDelegate = oAddrBook.AddressEntries
For i = 1 To oDelegate.Count
oAllSDC = oDelegate.Item(i)
'If oAllSDC.DisplayType = 1 Then
If oAllSDC.Name = "AllUsers" Then
Exit For
End If
' End If
Next

For i = 0 To CInt(oFolders.Count)
oFolder = CType(oFolders.GetNext, MAPI.Folder)
If CStr(oFolder.Name) = "Calendar" Then
Exit For
End If
Next

oACLs.CDOItem = oFolder
oNewACE.ID = oAllSDC.ID
oNewACE.Rights = ACLRIGHTS.ROLE_REVIEWER
oFolderACEs.Add(oNewACE)
oACLs.Update()
oSession.Logoff()

Catch ex As Exception
MsgBox(ex.Message & " --error setting delegates")
End Try
End Sub
sounddoc
Comments:

Post a Comment