Apr 212005
 

Perhaps this category will have obvious solutions or tips, but I’ll share them anyway: C# code snippets. This first one is about logging on to Outlook, which I needed for E-Sync. All samples give you the code with the name of the profile to logon to, or “leave the values for profile and password blank to use the default profile”. The first one means hard-coding a profile, the second one I did not get working on 2 different machines, so I guess it used to be like that but not anymore.

Here’s how to lookup the default profile in the registry, and logon to the MAPI-store.

RegistryKey myKey = Registry.CurrentUser;
myKey = myKey.OpenSubKey("SoftwareMicrosoftWindows NTCurrentVersionWindows Messaging SubsystemProfiles");
String myProfile = myKey.GetValue("DefaultProfile").ToString();
myMAPISession.Logon(myProfile,"",true,myMV,myMV,myMV,myMV);

Don’t forget to include “using Microsoft.Win32;”.

 Posted by at 21:01

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)