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