lContinuer = .F. oOutlook = CREATEOBJECT("Outlook.Application") IF VARTYPE( oOutlook) = "U" DO FORM ts_Messagebox WITH I("Outlook must be running") oOutlook = null RELEASE oOutlook QUIT ELSE oMapi = oOutlook.GetNamespace("MAPI") outlookAccounts = oMapi.Accounts FOR i = 1 TO outlookAccounts.Count IF outlookAccounts.Item(i).DisplayName = "anemail@mycompany.com" THEN lContinuer = .T. EXIT ENDIF ENDFOR outlookAccounts = null RELEASE outlookAccounts oMAPI = null RELEASE oMAPI IF !lContinuer DO FORM ts_Messagebox WITH I("You can't use the application.") oOutlook = null RELEASE oOutlook quit ENDIF ENDIF oOutlook = null RELEASE oOutlookEven after the adjustments I have the same problem. Couple of things to mention though. If I run my code through the debugger First execution runs ok. but after that I have to reboot my computer. If I run through compiled app the message "You can't use the application." is not even shown. and after the non-message I have to reboot my computer if I want to run that code again.
>>lcontinue = .F. >>oOutlook = CREATEOBJECT("Outlook.Application") >>IF VARTYPE( oOutlook) = "U" >> Messagebox( "Outlook must be running") >> oOutlook = null >> RELEASE oOutlook >> QUIT >>ELSE >> outlookAccounts = oOutlook.GetNamespace("MAPI").Accounts >> FOR i = 1 TO outlookAccounts.Count >> IF outlookAccounts.Item(i).DisplayName = "SomeEmail@mybusiness.com" THEN >> lcontinue = .T. >> EXIT >> ENDIF >> ENDFOR >> outlookAccounts = null >> RELEASE outlookAccounts >> >> IF !lcontinue >> Messagebox( "You can't use the application.") >> oOutlook = null >> RELEASE oOutlook >> quit >> ENDIF >>ENDIF >>oOutlook = null >>RELEASE oOutlook >>>>
>oMapi = oOutlook.GetNamespace("MAPI")
>outlookAccounts = oMapi.Accounts
>
>