Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / May 2004

Tip: Looking for answers? Try searching our database.

using redemption to auto-populate custom form fields.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Buddrige - 14 May 2004 04:46 GMT
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
David Buddrige - 14 May 2004 07:41 GMT
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. 8-)

> Hi all,
>
[quoted text clipped - 54 lines]
>
> David Buddrige
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.