Exemplo n.º 1
0
        public static void SendTestEmail(string emailAddress, string smtpServer, int smtpPort, bool useSSL, string smtpUsername, string smtpPassword)
        {
            // Send a test Email
            string emailMessage = CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.EmailUtils_TestEmail);
            string sendTo       = emailAddress;

            if (sendTo == null)
            {
                global::Controls.InputBoxResult result = global::Controls.InputBox.ShowDialog(null, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EnterValidEmail), "", null);

                if (result.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    sendTo = result.Value;
                }
                else
                {
                    return;
                }
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                ManagementInterfaceClient.ManagementInterface.SendTestEmail(ManagementInterfaceClient.AuthInfo, sendTo, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.EmailUtils_TestEmailSubject), emailMessage, smtpServer, smtpPort, useSSL, smtpUsername, smtpPassword);
                Cursor.Current = Cursors.Default;

                MessageBox.Show(String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.EmailUtils_EmailSuccess), sendTo), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailSent), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailProblem), sendTo, exception.Message), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailError), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btnSetupInstructions_Click(object sender, EventArgs e)
        {
            CheckSMTPSettings();

            // Decrypt our SMTP password
            //string smtpPassword = ManagementInterfaceClient.ManagementInterface.SMTPPassword;

            //if (smtpPassword.Length > 0)
            //    smtpPassword = WOSI.Utilities.CryptoUtils.Decrypt(smtpPassword, WOSI.CallButler.Data.Constants.EncryptionPassword);

            string messageString = Properties.Settings.Default.ExtensionClientSetupMail;

            messageString = messageString.Replace("#ExtNumber#", numExtNum.Value.ToString());

            if (txtPassword.Text == blankPassword)
            {
                messageString = messageString.Replace("#ExtPasscode#", CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionEditorForm_ContactAdmin));
            }
            else
            {
                messageString = messageString.Replace("#ExtPasscode#", txtPassword.Text.Trim());
            }

            messageString = messageString.Replace("#CallButlerServer#", "");
            messageString = messageString.Replace("#DownloadURL#", Properties.Settings.Default.ExtensionClientDownloadURL);

            string sendTo = txtEmailAddress.Text;

            if (sendTo.Length == 0)
            {
                global::Controls.InputBoxResult result = global::Controls.InputBox.ShowDialog(null, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionEditorForm_PleaseSpecifyEmail), "", null);

                if (result.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    sendTo = result.Value;
                }
                else
                {
                    return;
                }
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //WOSI.Utilities.EmailUtils.SendEmail("*****@*****.**", sendTo, Properties.LocalizedStrings.ExtensionEditorForm_YourNewExtension, messageString, ManagementInterfaceClient.ManagementInterface.SMTPServer, ManagementInterfaceClient.ManagementInterface.SMTPPort, ManagementInterfaceClient.ManagementInterface.SMTPUseSSL, ManagementInterfaceClient.ManagementInterface.SMTPUsername, smtpPassword);
                ManagementInterfaceClient.ManagementInterface.SendEmail(ManagementInterfaceClient.AuthInfo, sendTo, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.ExtensionEditorForm_YourNewExtension), messageString);
                MessageBox.Show(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailSentTo) + sendTo, CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailSent), MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exception)
            {
                MessageBox.Show(String.Format(CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailProblem), sendTo, exception.Message), CallButler.Manager.Utils.PrivateLabelUtils.ReplaceProductName(Properties.LocalizedStrings.Common_EmailError), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Cursor.Current = Cursors.Default;
        }