using redemption to auto-populate custom form fields.

D

David Buddrige

Hi all,

I am currently looking at Redemption (http://www.dimastr.com/redemption)
with a intent on buying it, to allow me to program Outlook forms without the
security prompts continuously being displayed.

While it seems fairly straight-forward (and well documented) to create an
email item and send it programmatically, what I am wanting to do is
auto-populate various fields in my custom outlook form with values that I
look up through CDO, and through outlook objects. At the moment the code
that does this is causing several security prompts to appear when I load the
form.

Here is my startup code:

Function Item_Open()
If item.size = 0 Then 'if in compose mode
dim myOlApp

set myOlApp = CreateObject("Outlook.Application")
Item.UserProperties("Req Name") = _
myOlApp.Application.GetNamespace("MAPI").CurrentUser.Name

Const CdoPR_BUSINESS_TELEPHONE_NUMBER = &H3A08001E
dim objSession
set objSession = CreateObject("MAPI.Session")
objSession.Logon ,,,False
For each objAddrList in objSession.AddressLists
If left(objAddrList.Name,19) = "Global Address List" _
or objAddrList.Name = "Offline Address Book" Then
'use online or offline version
'Get address entry from the GAL
Set objAddr = _
objAddrList.AddressEntries(objSession.CurrentUser.Name)
Item.UserProperties("Req Phone") = _
objAddr.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER)
exit for
End If
Next
objSession.Logoff
set objSession = Nothing
End If
End Function

Can anyone tell me how I go about obtaining the equivilent information
as:

myOlApp.Application.GetNamespace("MAPI").CurrentUser.Name

And

objAddr.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER)

Through redemption?

Thanks

David Buddrige
 
D

David Buddrige

Thanks to Dmitry, I was able to write equivilent code that works... Here it
is:

Function Item_Open()

If item.size = 0 Then 'if in compose mode

dim myUserObject

set myUserObject = _

CreateObject("Redemption.SafeCurrentUser")

Item.UserProperties("Req Name") =

myUserObject.Name

Const CdoPR_BUSINESS_TELEPHONE_NUMBER = _

&H3A08001E

Dim objAddr

Dim myAddressList

Set myAddressList = _

CreateObject("Redemption.AddressLists")

For objCounter = 1 to myAddressList.Count

If left(myAddressList(objCounter).Name,19) = _

"Global Address List" or _

myAddressList(objCounter).Name = _

"Offline Address Book" Then

'use online or offline version

'Get address entry from the GAL

Set objAddr = _


myAddressList(objCounter).AddressEntries(myUserObject.Name)

Item.UserProperties("Req Phone") = _


objAddr.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER)

exit for

End If

Next

End If

End Function

The main trick was to realise that myAddressList was

an array rather than being *exactly* the same as objSession.AddressLists in
the initial code example...

thanks heaps

David. :cool:
 

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