Help getting current user email address using Outlook Redemption???

K

Kristy

I am using an Exchange Server, Office XP, and have written a Com
add-in (VB6) and I need to get the default email address of the
current user.

I have been using this, which works OK but the
'objSession.CurrentUser' invokes security prompts ...

Set golApp = CreateObject("Outlook.Application")
Set objSession = golApp.CreateObject("MAPI.Session")
objSession.Logon "", "", False, False
Set objAddressEntry = objSession.CurrentUser
Set objFields = objAddressEntry.Fields
Set objMailAddresses = objFields.item(PR_EMS_AB_PROXY_ADDRESSES)

If Not objMailAddresses Is Nothing Then
strAddresses = objMailAddresses.Value

For IntCounter = LBound(strAddresses) To UBound(strAddresses)
strSMTP = strAddresses(IntCounter)

etc....

I would like to bypass the security prompts and have purchased Outlook
Redemption to help me with this, however I can't get it to work...

Set golApp = CreateObject("Outlook.Application")
Set objNameSpace = golApp.GetNamespace("MAPI")
Set objAddressEntry = CreateObject("Redemption.SafeCurrentUser")
Set objFields = objAddressEntry.Fields 'error occurring here
Set objMailAddresses = objFields.item(PR_EMS_AB_PROXY_ADDRESSES)

If Not objMailAddresses Is Nothing Then
strAddresses = objMailAddresses.Value

For IntCounter = LBound(strAddresses) To UBound(strAddresses)
strSMTP = strAddresses(IntCounter)

....

I am getting an error "wrong number of arguments or invalid property
assignment" on the following line

Set objFields = objAddressEntry.Fields

Am I going about this completely the wrong way? I have tried all sorts
of different methods from posts I have found but am not getting
anywhere, I am a newbie and my brain is about to explode, does anyone
have a code example of how to achieve this?

Please help me!
 
D

Dmitry Streblechenko

Unlike CDO, where Fields property on various objects returns a collection
(object), Fields in Redemption is an array property:

replace
Set objFields = objAddressEntry.Fields 'error occurring here
Set objMailAddresses = objFields.item(PR_EMS_AB_PROXY_ADDRESSES)
If Not objMailAddresses Is Nothing Then
strAddresses = objMailAddresses.Value

with
strAddresses = objAddressEntry.Fields(PR_EMS_AB_PROXY_ADDRESSES)
and check the return value type. If the propetty is missing, you will get
back Empty, otherwise a variant array of strings.

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

Kristy

Worked first time, no security prompts whatsoever! Thank you so much,
I have a lot of work to do with redemption over the next month (far
less than if I had to learn a whole other programming language though
- what an awesome product Redemption is) and from the first 2 lines of
your reply I already understand so much more.

Kristy
 

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