public void Run() { try { var handler = new DefaultMailClientHandler(); handler.AttachMailToHandler(); handler.AddSystemMailClientSettings(); handler.AddUserMailClientSettings(); } catch (Exception e) { MessageBox.Show("An error has occured while trying to set Inbox2 as default mail client, reason: " + e, "Error", MessageBoxButtons.OK); } }
void CheckNow_Click(object sender, RoutedEventArgs e) { // Check if Inbox2 is the default mail client var handler = new DefaultMailClientHandler(); if (!handler.IsDefaultMailClient()) { var result = Inbox2MessageBox.Show(Strings.NotYourDefaultMailClient, Inbox2MessageBoxButton.YesNo); if (result.Result == Inbox2MessageBoxResult.Yes) { var executable = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Inbox2DefaultMailClient.exe"); try { // Start set default mail client process as administrator if needed new Process { StartInfo = new ProcessStartInfo(executable) { UseShellExecute = true, Verb = "runas" } }.Start(); } catch (Exception ex) { Logger.Error("An error has occured while trying to start process. Exception = {0}", LogSource.UI, ex); } } } else { Inbox2MessageBox.Show(Strings.AlreadyDefaultMailClient, Inbox2MessageBoxButton.OK); } }