|
Cliff Jones
Posts: 5
Joined: 2011-03-18
|
I have recently purchased the Outlook Security Manager for 2010. I am using Visual Basic 6 and Outlook 2010. I watched the video on your website and duplicated the application exactly. It works perfectly. I have another much more involved app with Visual Basic 6 and have duplicated the code from your website video in it also. However, when I start the project and reach the line of code "OutlookSecurityManager1.ConnectTo olApp", I encounter an error that says "The object invoked has disconnected from its client". olApp is defined as Outlook.Application. I can see no difference in the code between the small app and the larger app with regards to the Security Manager. To add even more frustration to the mix, if I run the small VB6 app, that does the same as the web video, and then immediately run my larger app, my larger app (that had previously failed) now works fine (throws no errors). The larger app will continue to run without problems unless I restart Outlook. Have you seen this error and can you give me any clue at what to look at? |
|
Posted 18 Mar, 2011 15:42:03
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Cliff,
Thank you for the detailed description.
Could you please send me your project (or just the part of your project that contains Outlook Security Manager related code) for reviewing? I will try to find the cause of this behavior. |
|
Posted 21 Mar, 2011 06:02:26
|
|
Top
|
|
Cliff Jones
Posts: 5
Joined: 2011-03-18
|
Thanks for your response. I am unable to send the whole application as it is rather large. I have sent the portions of the code that I believe to be appropriate. You will see a reference to a form MDIMain. This is the MDI parent form for the project. On this form we have placed the Outlook Security Manager control. There are 3 sections of code that I have included. They are the global declarations set in one module, the call to Activate_Outlook that is another module and then the actual Activate_Outlook routine. This routine is also in a BAS module.
This program is designed to start up Outlook automatically. However, we haven't even attempted that part yet. We are starting up Outlook manually prior to starting the program.
The program has a problem when it hits the line of code "MDIMain.OutlookSecurityManager1.ConnectTo olApp". It is at that point that it gives the message about being disconnected fr om the client. I have highlighted the line of code that encounters an error.
' These are the global definitions in one BAS module
Global olApp As Outlook.Application 'Outlook application object.
Global olNS As Outlook.Namespace 'Outlook namespace object.
' This call is made in another BAS module
Call Activate_Outlook
' This is the routine that it calls that is in a 3rd BAS module
Public Sub Activate_Outlook()
'This routine will set the Outlook application and namespace objects. (All object variables associated
' with Outlook are declared Global)
'^1
Dim fOutlookStarted As Boolean
Dim fldr As Outlook.MAPIFolder
Dim FSO As FileSystemObject
Dim fOutlookRunning As Boolean ' ^42
Dim lErrNum As Long
Dim processes As Object ' ^42
Dim sQuery As String ' ^42
Dim wmi As Object ' ^42
On Error GoTo ErrorHandler ' ^42
fOutlookStarted = False
'Check to see if we are already in the process of starting Outlook.
If Dir("c:OutlookStarting.txt") <> "" Then Exit Sub
' ^42 Check processes to see if outlook.exe is already running
Set wmi = GetObject("winmgmts:")
sQuery = "sel ect * fr om win32_process wh ere name='outlook.exe'"
Set processes = wmi.execquery(sQuery)
fOutlookRunning = (processes.Count > 0)
If Not fOutlookRunning Then ' ^42
'Create a "flag" file to avoid starting multiple instances of Outlook.
Set FSO = New FileSystemObject
FSO.CreateTextFile "c:OutlookStarting.txt", True
'No current instance of Outlook running, start one.
Set olApp = New Outlook.Application
fOutlookStarted = True
Else
'Set olApp = Nothing ' ^44
[U]Set olApp = New Outlook.Application ' This is the one we are hitting[/U]
End If
DoEvents
' This control removes the security popup message
MDIMain.OutlookSecurityManager1.ConnectTo olApp
MDIMain.OutlookSecurityManager1.DisableOOMWarnings = True
Set olNS = olApp.GetNamespace("MAPI")
If Not fOutlookRunning Then
'Launch the "applet" which will provide the password when prompted.
Shell "SubmitPwd.exe" '^17
End If
For Each fldr In olNS.Folders '^1
If Left(fldr.Name, 7) = "Mailbox" Then
Set fldrMailbox = fldr
If fOutlookStarted Then
fldrMailbox.Display '^17
End If
Exit For
End If
Next fldr
ErrorHandler:
If Err.Number <> 0 Then
'If any error occurred, clear the objects and report the error.
Set olApp = Nothing
Set olNS = Nothing
'Call Log_Error(PS_CNSQL, app.EXEName, "Utilities", "Activate_Outlook", _
Err.Description, True, Err.Number, UserID)
End If
Set fldr = Nothing
Set FSO = Nothing
Set wmi = Nothing ' ^42
Set processes = Nothing ' ^42
End Sub |
|
Posted 21 Mar, 2011 14:32:19
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Cliff,
Thank you for the code sample.
Everything looks correct, the only thing I can suggest is using the following code:
Call MDIMain.OutlookSecurityManager1.ConnectTo(olApp)
Also, you can try to create a new instance of our component directly in your code above, i.e. not to use the component located on your form but create a new one. |
|
Posted 22 Mar, 2011 08:48:41
|
|
Top
|
|
Cliff Jones
Posts: 5
Joined: 2011-03-18
|
Thanks for your response.
I tried option 1 to use the CALL and I received the same exact error message about being being disconnected from the client
I would like to try your 2nd option but I am not sure how to instantiate a new instance of the component
I tried the following code:
Dim objOSM as OutlookSecurityManager ' This line of code has no problem
SET objOSM = New Outlook.....but at this point the intellisense does not recognize the OutlookSecurityManager for me to be able to declare it.
So...can you tell me how to instantiate a new instance and use it in my code, please? |
|
Posted 22 Mar, 2011 12:00:06
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Cliff,
Please try to use the following code:
Dim objOSM As AddInExpress.OutlookSecurityManager
' ...
Set objOSM = New AddInExpress.OutlookSecurityManager |
|
Posted 22 Mar, 2011 12:52:18
|
|
Top
|
|
Cliff Jones
Posts: 5
Joined: 2011-03-18
|
All of those options do not seem to be available.
I can do the following:
Dim objOSM as AddInExpressCtl.OutlookSecurityManager
Notice that it is AddInExpressCtl instead of AddInExpress
However, if I try to do the SET command, there is no option to set a new AddInExpress or AddInExpressCtl.
I type SET objOSM = New ....and the only option is AddIn. There is no AddInExpress or AddInExpressCtl.
Also...one other thing to add to the mix. If I move my Activate_Outlook code from a BAS module to the MDIMain form, I no longer get the error about being disconnected from the client. However, when I try to process an email, the Security warning screen still appears although I have put in the DisableOOMWarnings = True. |
|
Posted 22 Mar, 2011 13:09:23
|
|
Top
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2880
Joined: 2004-04-05
|
Hi Cliff,
Please send me your project (or some demo project with the same issue) for testing. I think it will be the fastest and simplest way to solve the issue with your project. |
|
Posted 23 Mar, 2011 08:34:41
|
|
Top
|
|
Cliff Jones
Posts: 5
Joined: 2011-03-18
|
How do I send you a zipped project? |
|
Posted 23 Mar, 2011 09:19:13
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18614
Joined: 2006-05-11
|
|
Posted 23 Mar, 2011 09:55:16
|
|
Top
|
|