Ejemplo n.º 1
0
    /// <summary>
    /// Method for loads account settings
    /// </summary>
    private void loadAccontSettings()
    {
        AccountSettings.AccountInfo acc_info = Facade.GetInstance().GetDefaultAccountInfo();

        if (acc_info != null)
        {
            TextBoxPassword.Text    = EncryptDescript.CriptDescript(acc_info.Password);
            TextBoxDisplayName.Text = acc_info.DisplayName;

            int i = 0;
            foreach (ListItem item in DropDownListIncomingServer.Items)
            {
                if (item.Text == acc_info.IncomingMailServer)
                {
                    DropDownListIncomingServer.SelectedIndex = i;
                }
                i++;
            }

            TextBoxEmailAddress.Text               = EncryptDescript.CriptDescript(acc_info.EmailAddress);
            TextBoxOutgoingServer.Text             = acc_info.OutgoingServer;
            TextBoxLoginID.Text                    = acc_info.LoginId;
            TextBoxPortIncoming.Text               = acc_info.PortIncomingServer.ToString();
            TextBoxPortOutgoing.Text               = acc_info.PortOutgoingServer.ToString();
            CheckBoxSecureConnection.Checked       = acc_info.IsIncomeSecureConnection;
            CheckBoxOutgoingSecure.Checked         = acc_info.IsOutgoingSecureConnection;
            CheckBoxOutgoingAuthentication.Checked = acc_info.IsOutgoingWithAuthentication;
            CheckBoxPortIncoming.Checked           = acc_info.PortIncomingChecked;
            CheckBoxPortOutgoing.Checked           = acc_info.PortOutgoingChecked;
            TextBoxIncomingServer.Text             = acc_info.IncomingNameMailServer;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Method used for send a message.
    /// </summary>
    /// <param name="message">The message will be send.</param>
    /// <param name="acc">The account information.</param>
    public void SendMail(Message message, AccountSettings acc)
    {
        AccountSettings.AccountInfo arrayAcc_info = acc.Acc_Info;

        try
        {
            if (arrayAcc_info != null)
            {
                message.From.Email = arrayAcc_info.EmailAddress;
                string outgoing  = arrayAcc_info.OutgoingServer;
                int    smtp_Port = arrayAcc_info.PortOutgoingServer;
                string email     = EncryptDescript.CriptDescript(arrayAcc_info.EmailAddress);
                string password  = EncryptDescript.CriptDescript(arrayAcc_info.Password);

                bool ssl  = arrayAcc_info.IsOutgoingSecureConnection;
                bool port = arrayAcc_info.PortOutgoingChecked;

                if (ssl)
                {
                    if (port)
                    {
                        ActiveUp.Net.Mail.SmtpClient.SendSsl(message, outgoing, smtp_Port, email, password, ActiveUp.Net.Mail.SaslMechanism.Login);
                    }
                    else
                    {
                        ActiveUp.Net.Mail.SmtpClient.SendSsl(message, outgoing, email, password, ActiveUp.Net.Mail.SaslMechanism.Login);
                    }
                }
                else
                {
                    if (port)
                    {
                        ActiveUp.Net.Mail.SmtpClient.Send(message, outgoing, smtp_Port, email, password, ActiveUp.Net.Mail.SaslMechanism.Login);
                    }
                    else
                    {
                        ActiveUp.Net.Mail.SmtpClient.SendSsl(message, outgoing, email, password, ActiveUp.Net.Mail.SaslMechanism.Login);
                    }
                }
                this.storeMessageSent(message);
            }
        }
        catch (Exception)
        {
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Connect the pop client.
    /// </summary>
    /// <param name="accountInfo">The information account</param>
    public void Connect(AccountSettings.AccountInfo accountInfo)
    {
        if (this._pop3Client == null || !this._pop3Client.IsConnected)
        {
            if (accountInfo != null && accountInfo.AccType == AccountType.POP3)
            {
                this._pop3Client = new Pop3Client();

                int    port       = accountInfo.PortIncomingServer;
                bool   ssl        = accountInfo.IsIncomeSecureConnection;
                string serverName = accountInfo.IncomingNameMailServer;
                string user       = EncryptDescript.CriptDescript(accountInfo.EmailAddress);
                string password   = EncryptDescript.CriptDescript(accountInfo.Password);
                bool   useInPort  = accountInfo.PortIncomingChecked;

                if (ssl)
                {
                    if (useInPort)
                    {
                        this._pop3Client.ConnectSsl(serverName, port, user, password);
                    }
                    else
                    {
                        this._pop3Client.ConnectSsl(serverName, user, password);
                    }
                }
                else
                {
                    if (useInPort)
                    {
                        this._pop3Client.Connect(serverName, port, user, password);
                    }
                    else
                    {
                        this._pop3Client.Connect(serverName, user, password);
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Event for confirms the settings displayed in the page
    /// </summary>
    /// <param name="sender">The sender object</param>
    /// <param name="e">The event arguments</param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        string emailAddress;
        string password;
        string displayName;
        string incomingMailServer;
        string outgoingServer;
        string loginId;
        string incomingNameMailServer;
        int    portIncomingServer = 0;
        int    portOutgoingServer = 0;
        bool   isIncomeSecureConnection;
        bool   isOutgoingSecureConnection;
        bool   isOutgoingWithAuthentication;

        emailAddress           = TextBoxEmailAddress.Text;
        password               = TextBoxPassword.Text;
        displayName            = TextBoxDisplayName.Text;
        incomingNameMailServer = TextBoxIncomingServer.Text;
        incomingMailServer     = DropDownListIncomingServer.SelectedValue;

        try
        {
            if (CheckBoxPortIncoming.Checked)
            {
                if (!TextBoxPortIncoming.Text.Equals(string.Empty))
                {
                    portIncomingServer = Convert.ToInt32(TextBoxPortIncoming.Text);

                    if (this.ImcomingWasChanged(portIncomingServer))
                    {
                        Facade.GetInstance().ChangeImcoming = true;
                    }
                }
            }
            if (CheckBoxPortOutgoing.Checked)
            {
                if (!TextBoxPortOutgoing.Text.Equals(string.Empty))
                {
                    portOutgoingServer = Convert.ToInt32(TextBoxPortOutgoing.Text);
                }
            }
        }
        catch (Exception)
        {
            Session["ErrorMessage"] = "The port must be an integer";
            Response.Redirect("~/ErrorPage.aspx");
        }

        isIncomeSecureConnection     = CheckBoxSecureConnection.Checked;
        isOutgoingSecureConnection   = CheckBoxOutgoingSecure.Checked;
        isOutgoingWithAuthentication = CheckBoxOutgoingAuthentication.Checked;

        loginId        = TextBoxLoginID.Text;
        outgoingServer = TextBoxOutgoingServer.Text;

        //These informations are going to save

        AccountSettings.AccountInfo acc_info = new AccountSettings.AccountInfo();
        acc_info.EmailAddress                 = EncryptDescript.CriptDescript(emailAddress);
        acc_info.Password                     = EncryptDescript.CriptDescript(password);
        acc_info.DisplayName                  = displayName;
        acc_info.IncomingMailServer           = incomingMailServer;
        acc_info.OutgoingServer               = outgoingServer;
        acc_info.LoginId                      = loginId;
        acc_info.PortIncomingServer           = portIncomingServer;
        acc_info.PortOutgoingServer           = portOutgoingServer;
        acc_info.IncomingNameMailServer       = incomingNameMailServer;
        acc_info.IsIncomeSecureConnection     = isIncomeSecureConnection;
        acc_info.IsOutgoingSecureConnection   = isOutgoingSecureConnection;
        acc_info.IsOutgoingWithAuthentication = isOutgoingWithAuthentication;
        acc_info.PortIncomingChecked          = CheckBoxPortIncoming.Checked;
        acc_info.PortOutgoingChecked          = CheckBoxPortOutgoing.Checked;

        Facade f = Facade.GetInstance();

        f.setAccountInfo(acc_info);
        f.SaveAccountSettings();

        try
        {
            f.Disconnect();
        }
        catch (Exception)
        {
            Facade.GetInstance().deleteAccountSettings();
            Session["ErrorMessage"] = "Could not be disconnected with imcoming server";
            Response.Redirect("~/ErrorPage.aspx");
        }
        try
        {
            f.Connect();
        }
        catch (Exception)
        {
            Facade.GetInstance().deleteAccountSettings();
            Session["ErrorMessage"] = "Could not be connected with imcoming server, review the account settings";
            //how the settings is not valid set null
            Facade.GetInstance().AccSettings = null;
            Response.Redirect("~/ErrorPage.aspx");
        }

        Session["SucessMessage"] = "Account Settings updated with success!";
        Response.Redirect("~/SucessPage.aspx");
    }