Check whether an user(account) is delegated to send mail on behalf

K

Kalyan

I need to programmatically check whether an user(account) is delegated to
"send mail on behalf of somebody" else. I'm referring to this feature in
outlook, in the outlook menu "Tools"-->"Options.."--> "Delegates" tab.

I can't able to figure out from VBA programming API. Could anybody pls help
to figure out this with VB/vbscript code?
 
K

Ken Slovak - [MVP - Outlook]

That's not available in the Outlook object model. You can read the folder
permissions using a lower level API such as CDO 1.21 or Redemption
(www.dimastr.com/redemption) or Extended MAPI (C++ or Delphi only).

Here's an example of reading folder permissions using CDO 1.21 (optional
installation for Outlook and mostly deprecated now):
http://www.cdolive.com/aclviewer.htm.

You can do similar things using those other API's. If you are using Outlook
2007 you could use similar code using Folder.PropertyAccessor to read the
ACL's. Of course then you'd need to interpret the data you get back.
 
D

Dmitry Streblechenko

Note that if a user has a permission to be a delegate, it does not
necessarily mean that the other user's mailbox will be added to
Tools"-->"Options.."--> "Delegates".
On the Extended MAPI level, you will need to work with the
PR_EMS_AB_PUBLIC_DELEGATES and PR_EMS_AB_PUBLIC_DELEGATES _BL_O MAPI
propeties exposed by a particular user.
Redemption exposes these collections through the RDOAddressEntry.Delegates
and RDOAddressEntry.IsDelegateFor collections.

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

Kalyan

Dnitry, Thanks much for coming in to help. I got it right in Redemption..

Ken : Could you pls provide some references for this CDO API libraray, the
one similar to Outlook Object Model API reference provided my Microsoft/MSDN?

I tried this vbscript, but got an "permission denied" error on the line
"Session.Logon"
 
K

Ken Slovak - [MVP - Outlook]

Do you have CDO installed?

It's an optional installation from the Office CD in versions prior to
Outlook 2007 and available as a separate download from MS for Outlook 2007.

You don't get any errors when you use CreateObject() or New on a
MAPI.Session?

The best source for CDO information and code is at the cdolive Web site.
That site also has a link to the CDO HLP file, and links to various KB
articles on CDO. The Digging Deeper Into CDO topic has a link to download a
zip of the CDO HLP.

There isn't really anything new for CDO since MS doesn't recommend it any
longer for anything but special development cases, no new development on it
has been done other than versioning updates for at least 6 years and it's
not supported for use in managed code. So CDOLive is the place to go.

If CDO is installed and registered then a Logon shouldn't occur if you have
any Outlook profiles on that machine. The best logon to use in that case is:

Session.Logon "", "", False, False

That will use an existing Outlook profile.
 
K

Kalyan

Ken:

I'm trying the following code to access the addressbook and the delegates
property. The code (with MAPI.Session) is running and I can able to select
entry from addressbook.I'm trying to access these properties

PR_EMS_AB_PUBLIC_DELEGATES &H8015000D
PR_EMS_AB_PUBLIC_DELEGATES_BL &H8110101E
PR_EMS_AB_PUBLIC_DELEGATES_BL_O &H8110000D

using Fields(prop) which returns nothing. Could u pls help me?

Code snippet:

Set objOutlook1 = CreateObject("Outlook.Application")
outlookObj.Application.ActiveExplorer.WindowState = 1 'Minimize
window
objOutlook1.ActiveExplorer.Activate()
Set olemSession = objOutlook1.CreateObject("MAPI.Session")
ReturnCode = olemSession.Logon( "", "", False, False, 0 )
Set myUser = olemSession.CurrentUser
objOutlook1.Application.ActiveExplorer.WindowState = 0
objOutlook1.ActiveExplorer.Activate()
Set colCDORecips = olemSession.AddressBook(Nothing,"Select
Recipients Names", False, True, 1,"To")
ScError=CStr(Err.number)
if StrComp(ScError,"-2147219963",1) = 0 then
mVar=MsgBox("Outlook is not running.",vbCritical,"Error")
exit function
end if
count=colCDORecips.Count
for i2003 = 1 to count
set entry=colCDORecips.Item(i2003)
MsgBox("DisplayType " & entry.AddressEntry.DisplayType)
MsgBox(TypeName(entry.AddressEntry))
if entry.AddressEntry.Type = "EX" then
set delegEntries=entry.AddressEntry.Fields(&H8015000E)
MsgBox TypeName(delegEntries)
MsgBox delegEntries
set delegEntries=entry.AddressEntry.Fields(&H8110000E)
MsgBox TypeName(delegEntries)
MsgBox delegEntries
set delegEntries=entry.AddressEntry.Fields(&H8110101F)
MsgBox TypeName(delegEntries)
MsgBox delegEntries
end if
.....

-Kalyan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top