hMailServer.Administrator.formConnect.AutoConnect C# (CSharp) Method

AutoConnect() public method

public AutoConnect ( ) : bool
return bool
        public bool AutoConnect()
        {
            if (userSettings.AutoConnectOnStartup)
             {
            string hostName = userSettings.AutoConnectServer;
            if (string.IsNullOrEmpty(hostName))
               return false;

            foreach (Server server in userSettings.ServerConnections.List)
            {
               if (server.hostName.ToUpper() == hostName.ToUpper())
               {
                  return Connect(server);
               }
            }
             }

             return false;
        }

Usage Example

Example #1
0
        static void Main()
        {
            // Hook up so that we can fetch unhandled events.
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(currentDomain_UnhandledException);
            System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(currentDomain_ThreadException);

            // What does this actually do...?
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            formConnect connectDlg = new formConnect();

            if (!connectDlg.AutoConnect())
            {
                if (connectDlg.ShowDialog() != DialogResult.OK)
                {
                    // We failed to connect. Exit app again.
                    return;
                }
            }

            hMailServer.Application application = connectDlg.Application;
            string serverHost = connectDlg.Server;

            System.Windows.Forms.Application.Run(new formMain(application, serverHost));

            if (application != null)
            {
                Marshal.ReleaseComObject(application);
            }
        }
All Usage Examples Of hMailServer.Administrator.formConnect::AutoConnect