private void butOK_Click(object sender, System.EventArgs e)
 {
     EmailAddressCur.SMTPserver    = PIn.String(textSMTPserver.Text);
     EmailAddressCur.EmailUsername = PIn.String(textUsername.Text);
     EmailAddressCur.EmailPassword = PIn.String(textPassword.Text);
     try{
         EmailAddressCur.ServerPort = PIn.Int(textPort.Text);
     }
     catch {
         MsgBox.Show(this, "invalid outgoing port number.");
     }
     EmailAddressCur.UseSSL             = checkSSL.Checked;
     EmailAddressCur.SenderAddress      = PIn.String(textSender.Text);
     EmailAddressCur.Pop3ServerIncoming = PIn.String(textSMTPserverIncoming.Text);
     try {
         EmailAddressCur.ServerPortIncoming = PIn.Int(textPortIncoming.Text);
     }
     catch {
         MsgBox.Show(this, "invalid incoming port number.");
     }
     if (IsNew)
     {
         EmailAddresses.Insert(EmailAddressCur);
     }
     else
     {
         EmailAddresses.Update(EmailAddressCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemple #2
0
        ///<summary>Inserts the new email address and returns it.</summary>
        public static EmailAddress CreateEmailAddress(string senderAddress = "", string emailUserName = "")
        {
            EmailAddress email = new EmailAddress();

            email.SenderAddress = senderAddress;
            if (senderAddress == "")
            {
                email.SenderAddress = "Email" + MiscUtils.CreateRandomAlphaNumericString(4);
            }
            email.EmailUsername = emailUserName;
            EmailAddresses.Insert(email);
            EmailAddresses.RefreshCache();
            return(email);
        }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     try {
         PIn.Int(textPort.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid outgoing port number.");
         return;
     }
     try {
         PIn.Int(textPortIncoming.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid incoming port number.");
         return;
     }
     if (string.IsNullOrWhiteSpace(textUsername.Text) ||
         !textUsername.Text.Contains("@"))                   //super basic validation
     {
         MsgBox.Show(this, "Please enter a valid email address.");
         return;
     }
     if (EmailAddresses.AddressExists(textUsername.Text, EmailAddressCur.EmailAddressNum))
     {
         MsgBox.Show(this, "This email address already exists.");
         return;
     }
     EmailAddressCur.SMTPserver         = PIn.String(textSMTPserver.Text);
     EmailAddressCur.EmailUsername      = PIn.String(textUsername.Text);
     EmailAddressCur.EmailPassword      = PIn.String(MiscUtils.Encrypt(textPassword.Text));
     EmailAddressCur.ServerPort         = PIn.Int(textPort.Text);
     EmailAddressCur.UseSSL             = checkSSL.Checked;
     EmailAddressCur.SenderAddress      = PIn.String(textSender.Text);
     EmailAddressCur.Pop3ServerIncoming = PIn.String(textSMTPserverIncoming.Text);
     EmailAddressCur.ServerPortIncoming = PIn.Int(textPortIncoming.Text);
     if (IsNew)
     {
         EmailAddresses.Insert(EmailAddressCur);
     }
     else
     {
         EmailAddresses.Update(EmailAddressCur);
     }
     DialogResult = DialogResult.OK;
 }
Exemple #4
0
        public static EmailAddress InsertEmailAddress()
        {
            EmailAddress email = new EmailAddress()
            {
                SenderAddress      = TestEmaiAddress,
                EmailUsername      = TestEmaiAddress,
                EmailPassword      = MiscUtils.Encrypt(TestEmaiPwd),
                ServerPort         = 587,
                UseSSL             = true,
                Pop3ServerIncoming = "pop.gmail.com",
                ServerPortIncoming = 110,
                SMTPserver         = "smtp.gmail.com",
                UserNum            = 0,
                WebmailProvNum     = 0,
            };

            EmailAddresses.Insert(email);
            return(email);
        }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     try {
         PIn.Int(textPort.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid outgoing port number.");
         return;
     }
     try {
         PIn.Int(textPortIncoming.Text);
     }
     catch {
         MsgBox.Show(this, "Invalid incoming port number.");
         return;
     }
     if (string.IsNullOrWhiteSpace(textUsername.Text))
     {
         MsgBox.Show(this, "Please enter a valid email address.");
         return;
     }
     //Only checks against non-user email addresses.
     if (EmailAddresses.AddressExists(textUsername.Text, _emailAddressCur.EmailAddressNum))
     {
         MsgBox.Show(this, "This email address already exists.");
         return;
     }
     if (!textPassword.Text.IsNullOrEmpty() && !textAccessToken.Text.IsNullOrEmpty())
     {
         MsgBox.Show(this, "There is an email password and access token entered.  Please clear one and try again.");
         return;
     }
     _emailAddressCur.AccessToken  = textAccessToken.Text;
     _emailAddressCur.RefreshToken = textRefreshToken.Text;
     if (!_isNew && (!string.IsNullOrWhiteSpace(_emailAddressCur.AccessToken) || !string.IsNullOrWhiteSpace(_emailAddressCur.RefreshToken)) &&        //If has a token
         (_emailAddressCur.SMTPserver != PIn.String(textSMTPserver.Text) || _emailAddressCur.Pop3ServerIncoming != PIn.String(textSMTPserverIncoming.Text)))               //And changed a server
     {
         if (!MsgBox.Show(MsgBoxButtons.OKCancel, "There is an access token associated to this email address.  "
                          + "Changing servers will wipe out the access token and may require reauthentication.  Continue?"))
         {
             return;
         }
         _emailAddressCur.AccessToken  = "";
         _emailAddressCur.RefreshToken = "";
         //TODO: If this is a google token, we may want to tell Google we no longer require access to their account.
         //This will limit our total number of active users
     }
     _emailAddressCur.SMTPserver         = PIn.String(textSMTPserver.Text);
     _emailAddressCur.EmailUsername      = PIn.String(textUsername.Text);
     _emailAddressCur.EmailPassword      = PIn.String(MiscUtils.Encrypt(textPassword.Text));
     _emailAddressCur.ServerPort         = PIn.Int(textPort.Text);
     _emailAddressCur.UseSSL             = checkSSL.Checked;
     _emailAddressCur.SenderAddress      = PIn.String(textSender.Text);
     _emailAddressCur.Pop3ServerIncoming = PIn.String(textSMTPserverIncoming.Text);
     _emailAddressCur.ServerPortIncoming = PIn.Int(textPortIncoming.Text);
     _emailAddressCur.UserNum            = ((Userod)(textUserod.Tag))?.UserNum ?? 0;
     if (_isNew)
     {
         EmailAddresses.Insert(_emailAddressCur);
     }
     else
     {
         EmailAddresses.Update(_emailAddressCur);
     }
     DialogResult = DialogResult.OK;
 }