![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi there,
I'm creating a synchronisation program which wil synchronise data between Outlook and our own database. We want our program to work with Outlook 2000 and up. The program is made with VB 2005 to communicate with a standalone Outlook 2000/2003 Outlook client. The problem I have is connecting with Outlook. When the program starts, there can be 3 situations: 1. Outlook.exe isn't running 2. Outlook is running but invisible (Application.Explorers.Count=0) 3. Outlook is running visible This is my startup code: olApplication = New Outlook.Application msgbox (olApplication.Version) Now I discribe the above 3 situations from both Outlook 2000 and 2003 ---Outlook 2003 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2003 situation 2----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. Every time when I start my program, a new instance of Outlook.exe is started!! That's not what I want. ---Outlook 2003 situation 3----------------------------------------------- Outlook not started again, that's good. The program starts with no errors, I can interact with Outlook. This is what I want! ---Outlook 2000 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2000 situation 2----------------------------------------------- Outlook isn't started, it will give the following error when it want's to execute the line msgbox (olApplication.Version) System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2146788252 Message="Exception from HRESULT: 0x800A9C64" Source="mscorlib" StackTrace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.VisualBasic.CompilerServices.VBBinder.In vokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters) at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) at Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 41 at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Obje ct sender, EventArgs e) in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 23 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m) at System.Windows.Forms.ContainerControl.WndProc(Mess age& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolea n value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Outlook_CRM_Sync.AGENDA_MAIN.Main() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.Designer.vb:line 2 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context( Object state) at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() ---Outlook 2000 situation 3----------------------------------------------- Same as Outlook 2000 situation 2 What I am doing wrong???? Anyone?? Tx a lot, Dikbill, The Netherlands |
#2
|
|||
|
|||
![]()
If you want Outlook visible when you don't have a UI you can add an Explorer
to the Explorers collection. Get a MAPIFolder object (like Inbox for example) and use that object in the Add method of the Explorers collection object. Make sure in those cases that you logon to the NameSpace object. Usually instead of New or CreateObject you would use GetObject to see first if Outlook was running. Even if you do use New you can only have 1 instance of Outlook running so it should attach to that instance. Then a check for Explorers.Count tells you if there is/was a UI. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dikbill" wrote in message ... Hi there, I'm creating a synchronisation program which wil synchronise data between Outlook and our own database. We want our program to work with Outlook 2000 and up. The program is made with VB 2005 to communicate with a standalone Outlook 2000/2003 Outlook client. The problem I have is connecting with Outlook. When the program starts, there can be 3 situations: 1. Outlook.exe isn't running 2. Outlook is running but invisible (Application.Explorers.Count=0) 3. Outlook is running visible This is my startup code: olApplication = New Outlook.Application msgbox (olApplication.Version) Now I discribe the above 3 situations from both Outlook 2000 and 2003 ---Outlook 2003 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2003 situation 2----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. Every time when I start my program, a new instance of Outlook.exe is started!! That's not what I want. ---Outlook 2003 situation 3----------------------------------------------- Outlook not started again, that's good. The program starts with no errors, I can interact with Outlook. This is what I want! ---Outlook 2000 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2000 situation 2----------------------------------------------- Outlook isn't started, it will give the following error when it want's to execute the line msgbox (olApplication.Version) System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2146788252 Message="Exception from HRESULT: 0x800A9C64" Source="mscorlib" StackTrace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.VisualBasic.CompilerServices.VBBinder.In vokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters) at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) at Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 41 at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Obje ct sender, EventArgs e) in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 23 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m) at System.Windows.Forms.ContainerControl.WndProc(Mess age& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolea n value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Outlook_CRM_Sync.AGENDA_MAIN.Main() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.Designer.vb:line 2 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context( Object state) at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() ---Outlook 2000 situation 3----------------------------------------------- Same as Outlook 2000 situation 2 What I am doing wrong???? Anyone?? Tx a lot, Dikbill, The Netherlands |
#4
|
|||
|
|||
![]()
Hmm. Normally I would expect GetObject used that way to not create a new
instance of Outlook but to return Nothing if no object was running. Then I'd use CreateObject. I certainly would not use both New and CreateObject. I'm not sure about that Try...Catch block. What you really want to do is test for the OL object being Nothing after using GetObject and then use CreateObject if needed. Then I'd test for the OL object not being Nothing before trying to get the NameSpace object. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dikbill" wrote in message . .. Ken, Thnx again. I've tried the 'GetObject' method, sorry for not mentioning that in my question, and that seems to work because when an Outlook.exe is running, that instance of Outlook is put in the variable which I use. olApplication If no Outlook.exe is running a new one will be started, invisible. Dim olApplication as object = Nothing Try olApplication = GetObject(, "Outlook.Application") Catch olApplication = New Outlook.Application olApplication = CreateObject("Outlook.Application") End Try But then when I want to do the next: Dim olns as object = olApplication.getNamespace("MAPI") Then I get the error Exception from HRESULT: 0x800A9C64 Do you have a clue??? Right now I'm re-installing office 2000, because maybe something has become corrupt or something. Tx, Dikbill, The Netherlands |
#5
|
|||
|
|||
![]()
Ken,
Thnx for your quick response! My example wasn't right, it's very hot here at the moment, about 34 degrees Celcius at the moment, so .... I have only one line in the catch and that is: Dim olApplication as object = Nothing Try olApplication = GetObject(, "Outlook.Application") Catch olApplication = CreateObject("Outlook.Application") End Try I use the try catch, or I could use on error resume next, code because if no Outlook.exe is running, I get the error: "Cannot create ActiveX component." But I think the problem is that a new Outlook.exe is started for a short moment and then is killed again by something, not by me, and that the olApplication which is returned from the GetObject call tries to connect with an Outlook.exe instance which isn't there anymore. Any suggestions, otherwise I hav e to trie something else, I don't know what yet. It would be nice to know how to get the current Oultook version before Outlook is started. Do you have a solution for that? Tnx again, Dikbill, The Netherlands "Ken Slovak - [MVP - Outlook]" schreef in bericht ... Hmm. Normally I would expect GetObject used that way to not create a new instance of Outlook but to return Nothing if no object was running. Then I'd use CreateObject. I certainly would not use both New and CreateObject. I'm not sure about that Try...Catch block. What you really want to do is test for the OL object being Nothing after using GetObject and then use CreateObject if needed. Then I'd test for the OL object not being Nothing before trying to get the NameSpace object. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dikbill" wrote in message . .. Ken, Thnx again. I've tried the 'GetObject' method, sorry for not mentioning that in my question, and that seems to work because when an Outlook.exe is running, that instance of Outlook is put in the variable which I use. olApplication If no Outlook.exe is running a new one will be started, invisible. Dim olApplication as object = Nothing Try olApplication = GetObject(, "Outlook.Application") Catch olApplication = New Outlook.Application olApplication = CreateObject("Outlook.Application") End Try But then when I want to do the next: Dim olns as object = olApplication.getNamespace("MAPI") Then I get the error Exception from HRESULT: 0x800A9C64 Do you have a clue??? Right now I'm re-installing office 2000, because maybe something has become corrupt or something. Tx, Dikbill, The Netherlands |
#6
|
|||
|
|||
![]()
Well, the first thing you have to do is figure out why Outlook is being
terminated. I'd have no idea why that's happening. There are a number of ways to find the Outlook version, most involve registry scanning. HKCR\Outlook.Application\CurVer is one of them. The default value will be something like "Outlook.Application.11" for Outlook 2003, "Outlook.Application.10" for Outlook 2002, etc. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dikbill" wrote in message . .. Ken, Thnx for your quick response! My example wasn't right, it's very hot here at the moment, about 34 degrees Celcius at the moment, so .... I have only one line in the catch and that is: Dim olApplication as object = Nothing Try olApplication = GetObject(, "Outlook.Application") Catch olApplication = CreateObject("Outlook.Application") End Try I use the try catch, or I could use on error resume next, code because if no Outlook.exe is running, I get the error: "Cannot create ActiveX component." But I think the problem is that a new Outlook.exe is started for a short moment and then is killed again by something, not by me, and that the olApplication which is returned from the GetObject call tries to connect with an Outlook.exe instance which isn't there anymore. Any suggestions, otherwise I hav e to trie something else, I don't know what yet. It would be nice to know how to get the current Oultook version before Outlook is started. Do you have a solution for that? Tnx again, Dikbill, The Netherlands |
#7
|
|||
|
|||
![]()
Ken,
Re-installing did'nt solve the problem! Just for your information. Dikbill, The Netherlands "Ken Slovak - [MVP - Outlook]" schreef in bericht ... If you want Outlook visible when you don't have a UI you can add an Explorer to the Explorers collection. Get a MAPIFolder object (like Inbox for example) and use that object in the Add method of the Explorers collection object. Make sure in those cases that you logon to the NameSpace object. Usually instead of New or CreateObject you would use GetObject to see first if Outlook was running. Even if you do use New you can only have 1 instance of Outlook running so it should attach to that instance. Then a check for Explorers.Count tells you if there is/was a UI. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Dikbill" wrote in message ... Hi there, I'm creating a synchronisation program which wil synchronise data between Outlook and our own database. We want our program to work with Outlook 2000 and up. The program is made with VB 2005 to communicate with a standalone Outlook 2000/2003 Outlook client. The problem I have is connecting with Outlook. When the program starts, there can be 3 situations: 1. Outlook.exe isn't running 2. Outlook is running but invisible (Application.Explorers.Count=0) 3. Outlook is running visible This is my startup code: olApplication = New Outlook.Application msgbox (olApplication.Version) Now I discribe the above 3 situations from both Outlook 2000 and 2003 ---Outlook 2003 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2003 situation 2----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. Every time when I start my program, a new instance of Outlook.exe is started!! That's not what I want. ---Outlook 2003 situation 3----------------------------------------------- Outlook not started again, that's good. The program starts with no errors, I can interact with Outlook. This is what I want! ---Outlook 2000 situation 1----------------------------------------------- Outlook is started but unvisible, that's not what I want. The program starts with no errors, I can interact with Outlook. ---Outlook 2000 situation 2----------------------------------------------- Outlook isn't started, it will give the following error when it want's to execute the line msgbox (olApplication.Version) System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2146788252 Message="Exception from HRESULT: 0x800A9C64" Source="mscorlib" StackTrace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.VisualBasic.CompilerServices.VBBinder.In vokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters) at Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) at Microsoft.VisualBasic.CompilerServices.NewLateBind ing.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 41 at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Obje ct sender, EventArgs e) in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.vb:line 23 at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m) at System.Windows.Forms.ContainerControl.WndProc(Mess age& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolea n value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Outlook_CRM_Sync.AGENDA_MAIN.Main() in C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CR M_Sync\AGENDA_MAIN.Designer.vb:line 2 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context( Object state) at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() ---Outlook 2000 situation 3----------------------------------------------- Same as Outlook 2000 situation 2 What I am doing wrong???? Anyone?? Tx a lot, Dikbill, The Netherlands |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2003 startup | chemnut94707 | Outlook - Using Contacts | 1 | May 5th 06 11:13 PM |
Implementation differences in VS 2003 and VS 2005 regarding outloo | Peeyush | Outlook - Using Forms | 1 | April 17th 06 01:35 PM |
Outlook 200 won't shut down ... | Grumpy Aero Guy | Outlook - General Queries | 2 | April 10th 06 01:33 PM |
Outlook 2003 crash on startup in WinXP | [email protected] | Outlook - General Queries | 0 | February 21st 06 07:02 PM |
Outlook 2003 startup script error | [email protected] | Outlook - General Queries | 0 | January 24th 06 07:34 PM |