Exchange Cached Mode through VB.net

Joined
Dec 23, 2009
Messages
2
Reaction score
0
Hi guys,

This is my first thread here so I'll first of all say hello to everyone!

My problem is the following :

I am trying to get the status of Exchange Cached mode for MS-Outlook for a remote PC using VB.net. So far, I have found this.

Code:
 mstrHostName = HostNameTextBox.Text 
 
Dim MyReg As Microsoft.Win32.RegistryKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, mstrHostName)
 
Dim MyRegKey As Microsoft.Win32.RegistryKey
 
 
 
Dim MyVal As String
 
 
 
Dim strProfileName As String = InputBox("Please input Profile Name", "Profile Input", "Default")
 
MyRegKey = MyReg.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" & strProfileName & "\13dbb0c8aa05101a9bb000aa002fc45a")
 
MyVal = MyRegKey.GetValue("00036601")
 
MyRegKey.Close()
 
If MyVal = "04 00 00 00" Then
 
 
 
RichTextBox1.Text = "Exchange cached mode is disabled for profile " & strProfileName
 
ElseIf MyVal = "84 01 00 00" Then
 
 
 
RichTextBox1.Text = "Exchange cached mode is enabled for profile " & strProfileName
 
ElseIf MyVal = "84 05 00 00" Then
 
 
 
RichTextBox1.Text = "Exchange cached mode is enabled with public folders and favourites for profile " & strProfileName
 
End If



When I put in the remote hostname, it should prompt the user to input the Outlook Profile to look up. Then, using about the same code, with another button, I could either turn on or off the cached mode.

But when I click on the button to get the status, I do get prompted for a profile name. But then, I get his error at the registry key lookup :

Code:
System.NullReferenceException was unhandled
Message=Object reference not set to an instance of an object.
Source=MHC 1st level toolkit
StackTrace:
	 at AD_Exchange_info.Main.GetCachedStatusButton_Click(Object sender, EventArgs e) in D:\Documents and Settings\""User Profile hidden by author""\my documents\visual studio 2010\Projects\AD Exchange info\AD Exchange info\Main.vb:line 188
	 at System.Windows.Forms.Control.OnClick(EventArgs e)
	 at System.Windows.Forms.Button.OnClick(EventArgs e)
	 at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
	 at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
	 at System.Windows.Forms.Control.WndProc(Message& m)
	 at System.Windows.Forms.ButtonBase.WndProc(Message& m)
	 at System.Windows.Forms.Button.WndProc(Message& m)
	 at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
	 at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
	 at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
	 at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
	 at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
	 at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
	 at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
	 at System.Windows.Forms.Application.Run(ApplicationContext context)
	 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
	 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
	 at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
	 at AD_Exchange_info.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
	 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
	 at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
	 at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
	 at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
	 at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
	 at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
	 at System.Threading.ThreadHelper.ThreadStart()
InnerException:



Anyone to help out on this?

Thanks!

 
Last edited:
Back
Top