Hi all i wish my app to assign task to users via Outlook, been having huge problems with the 8007007e error having a certain reg key that stops outlook being instantiated so thinking back to my VB6 days i know you can get hold of instance that is open via the following
Code:
'Use Getobject method incase outlook is already open
Set objApp = GetObject(, "Outlook.Application")
I upgraded it to VB.NET and added a few examples of accessing the late-bound object:
VB.NET:
Dim objApp As Object = GetObject(, "Outlook.Application")
objApp.FooMethod()
x = objApp.FooProperty
x = objApp.FooFunction(i, j)
The C# equivalent is:
System.Type objAppType = System.Type.GetTypeFromProgID("Outlook.Application");
object objApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application");
objAppType.InvokeMember("FooMethod", System.Reflection.BindingFlags.InvokeMethod, null, objApp, null);
x = objAppType.InvokeMember("FooProperty", System.Reflection.BindingFlags.GetProperty, null, objApp, null);
x = objAppType.InvokeMember("FooFunction", System.Reflection.BindingFlags.InvokeMethod, null, objApp, new object[] {i, j});
I know this looks complicated, but the VB GetObject and CreateObject (and the subsequent calls to the late-bound object) do a lot behind the scenes.
Thanks David played about with what you posted i came up with a slightly different approach. Just wanting know would just suggest using yours or the one i have used ? please see the attached files.