Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Ken Blum
  Where is Ken Blum?
 Chicago
 Illinois - United States
 Ken Blum
 Tags
Subject: Outlook Logoff/Logon now working
Thread ID: 194418 Message ID: 194418 # Views: 46 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Monday, September 15, 2008 7:28:49 PM         
   


I've been using the following code in a program to change the mailbox in Outlook 2003 SP1 for 5+ years. Starting last week the logoff and logon methods do nothing, it just remains in my default profile. As a test I told Outlook to prompt for a profile, and with that I am able to change to the mailbox. Any ideas?

SET MESSAGE TO "Calling Outlook. Please Wait..."
processed_one = 0
DO WHILE(processed_one < 2)
	loOutlook = NewObject("Outlook.Application") && Get Outlook up & running
	IF VARTYPE(loOutlook) != 'O'
		THIS.CleanUp
		MSB("Microsoft Outlook and Excel 2000 are required for this function.")
		SET MESSAGE TO
		THIS.Enabled = .T.
		RETURN
	ENDIF

SET STEP ON 

	loSpace = loOutlook.GetNameSpace("MAPI")  		&& Reference MAPI NameSpace	
	IF VARTYPE(loSpace) != 'O'
		MSB("No MAPI NameSpace in Outlook - Contact IS Department")
		SET MESSAGE TO
		THIS.Enabled = .T.
		RETURN
	ENDIF 


	loSpace.logoff()
	loSpace.logon("ExpenseReports","",.F.)
	oSafeUser = CREATEOBJECT("Redemption.SafeCurrentUser")
	IF oSafeUser.Name != "Expense Reports"	&& Need Expense Reports Profile
		SET MESSAGE TO "Logging off from "+oSafeUser.Name
		loSpace.logoff
		loSpace.logon("ExpenseReports","",.T.)
		oSafeUser = CREATEOBJECT("Redemption.SafeCurrentUser")
		IF oSafeUser.Name != "Expense Reports"
			loOutlook.Quit
			IF processed_one = 1
				MSB("Cannot access the Expense Reports Outlook Profile - Contact IS Department")
				SET MESSAGE TO
				THIS.Enabled = .T.
				THIS.CleanUp
				RETURN
			ENDIF
			processed_one = 1		
		ELSE
			processed_one = 2
		ENDIF
	ELSE
		processed_one = 2	
	ENDIF
ENDDO





KTB



COMPLETE THREAD
Outlook Logoff/Logon now working Posted by Ken Blum @ 9/15/2008 7:28:49 PM