applescript and MS outlook problems

Hey all,

I’m trying to build an applescript (applescript studio) that will allow me to streamline the creation of business proposals. The first step is to address the clients.

I have a window that allows me to either select from an existing client stored in Microsoft Outlook or to enter the information into text fields for a new client. If I enter the new client’s info and click the appropriate button I get Event Handler failures.

In addition I while I am able to get a list of all of my outlook contacts when I select one applescript is unable to pull the contact’s relevant data and insert it into the text fields.

I’m pulling my hair out… so hopefully a fresh set of eyes will help…

-on clicked theObject
	
	if title of theObject = "Get Client" then
		--get all contacts and populate a list
		set clientList to {}
		tell application "Microsoft Outlook"
			set theContacts to contacts
			repeat with theContact in theContacts
				set theName to display name of theContact
				copy theName to the end of clientList
			end repeat
		end tell
		choose from list clientList with prompt "Choose Client"
		set listchoice to result as text
		--select the client and have the info populate text fields in the main window this fails
		tell application "Microsoft Outlook"
			--set contacts to theName
			--open contact {display name:theName}
			--set theName to display name of theName
			set theContacts to contacts
			--get contact theName
			set theStreet to home street address of listchoice
			set theCity to home city of listchoice
			set theState to home state of listchoice
			set theZip to home zip of listchoice
			set theEmail to email addresses of listchoice
		end tell
		
		tell window "newProposal"
			set contents of text field "clientName" to listchoice
			set contents of text field "clientName" to theName
			set contents of text field "streetAddress" to theAddress
			set contents of text field "clientCity" to theCity
			set contents of text field "clientState" to theState
			set contents of text field "clientZip" to theZip
			set contents of text field "clientEmail" to theEmail
		end tell
	
	-- create new client from user-entered values into text fields.  Event handler fail		
	else if title of theObject = "New Client" then
		set displayName to the contents of text field "clientName" of window 1
		set theAddress to the contents of text field "streetAddress" of window 1
		set city to the contents of text field "clientCity" of window 1
		set theState to the contents of text field "clientState" of window 1
		set zip to the contents of text field "clientZip" of window 1
		set thePhone to the contents of text field "clientPhone" of window 1
		--set theEmail to the contents of text field "clientEmail" of window 1
		tell application "Microsoft Outlook"
			activate
			make new contact with properties {display name:displayName, home street address:theAddress, home city:city, home state:theState, home zip:zip, phone:thePhone}
		end tell
		
	else if title of theObject = "next" then
		
		--display dialog "here we open word and create the proposal..."
		
		--tell application "Microsoft Word" 
		--	make new document with properties {attached template:"path:to:template:here.dot"}
		--end tell
		tell application "Microsoft Outlook"
			quit
		end tell
	end if
	
end clicked