예제 #1
0
        public bool AddEmail(NewEmail newEmail)
        {
            int rowsAffected = 0;

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(SQL_AddEmail, conn);
                    cmd.Parameters.AddWithValue("@firstname", newEmail.FirstName);
                    cmd.Parameters.AddWithValue("@lastname", newEmail.LastName);
                    cmd.Parameters.AddWithValue("@emailAddress", newEmail.EmailAddress);
                    cmd.Parameters.AddWithValue("@phoneNumber", newEmail.PhoneNumber);
                    cmd.Parameters.AddWithValue("@address", newEmail.Address);

                    rowsAffected = cmd.ExecuteNonQuery();
                }
            }
            catch (SqlException ex)
            {
                //log exception
            }

            return(rowsAffected > 0);
        }
        public int ChangeEmail(NewEmail ne)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    command    = new SqlCommand("usp_changeEmail");

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@UserID", ne.UserID));
            command.Parameters.Add(new SqlParameter("@NewEmail", ne.NewEmailString));
            command.Connection = connection;

            connection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            connection.Close();

            if (table.Rows[0][0].ToString() == ne.NewEmailString)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (OldEmail != null)
         {
             hashCode = hashCode * 59 + OldEmail.GetHashCode();
         }
         if (NewEmail != null)
         {
             hashCode = hashCode * 59 + NewEmail.GetHashCode();
         }
         if (FirstName != null)
         {
             hashCode = hashCode * 59 + FirstName.GetHashCode();
         }
         if (LastName != null)
         {
             hashCode = hashCode * 59 + LastName.GetHashCode();
         }
         if (IsActive != null)
         {
             hashCode = hashCode * 59 + IsActive.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #4
0
        private void SendEmail(NewEmail newEmail)
        {
            dynamic email = new Email("NewEmailPage");

            email.To        = newEmail.EmailAddress;
            email.FirstName = newEmail.FirstName;
            email.Send();
        }
 public async Task SendRawEmailTest()
 {
     await NewEmail
     .Create("This is a raw email test from the .NET SDK.")
     .To(To, Cc, Bcc)
     .From("*****@*****.**", "*****@*****.**")
     .WithBody("This is a raw body email.")
     .SendAsync();
 }
 public async Task SendEmailWithSmtpTest()
 {
     await NewEmail
     .Create("This is a raw email test from the .NET SDK.")
     .To(To, Cc, Bcc)
     .From("*****@*****.**", "*****@*****.**")
     .WithBody("This is a raw body email.", false)
     .Using("smtp.gmail.com", 465, Username, Password)
     .SendAsync();
 }
 public bool CanAttach()
 {
     if (NewEmail.Get().CanDispose())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #8
0
        public void ChangeEmailTest()
        {
            NewEmail ne = new NewEmail();

            ne.UserID         = GetUserID();
            ne.NewEmailString = "TESTEMAIL2";

            int result = controller.ChangeEmail(ne);

            Assert.AreEqual(result, 1);
        }
예제 #9
0
        public ActionResult EmailSignUp(NewEmail newEmail)
        {
            if (!ModelState.IsValid)
            {
                return(View("EmailSignUp", newEmail));
            }

            mailingListDAL.AddEmail(newEmail);
            //SendEmail(newEmail);

            return(RedirectToAction("Index"));
        }
예제 #10
0
 public void OnPostReply(String id)
 {
     if (!String.IsNullOrEmpty(id))
     {
         ReplyID = "";
         var myEmail = GetEmailByID(id);
         if (myEmail == null)
         {
             Redirect("/Error");
             return;
         }
         if (myEmail != null)
         {
             Email email = new Email();
             email.Body           = myNewEmail.Body;
             email.TimeSent       = DateTime.Now;
             email.UserIDTo       = myEmail.UserIDFrom;
             email.UserIDFrom     = myEmail.UserIDTo;
             email.EmailRepliedTo = myEmail.id;
             myContext.myEmails.Add(email);
             myNewEmail.Body      = "";
             myNewEmail.From      = "";
             myNewEmail.ReplyBody = "";
             myNewEmail.To        = "";
             myContext.SaveChanges();
         }
     }
     else
     {
         //Check if user exists:
         UserData Recipient;
         UserData Writer;
         if (VerifyUsersInfo(out Recipient, out Writer))
         {
             Email email = new Email();
             email.Body       = myNewEmail.Body;
             email.TimeSent   = DateTime.Now;
             email.UserIDTo   = Recipient.Id;
             email.UserIDFrom = Writer.Id;
             myContext.myEmails.Add(email);
             myContext.SaveChanges();
             Error      = "Success!";
             myNewEmail = new NewEmail();
         }
         else
         {
             Error = "Failed to send!";
         }
     }
 }
예제 #11
0
        public void OnGet()
        {
            string ID = (String)RouteData.Values["emailid"];
            int    TryGetInt;

            UpdateEmails();

            if (int.TryParse(ID, out TryGetInt))
            {
                if (!String.IsNullOrEmpty(ID))
                {
                    var EmailThing = MailToMe.Where(delegate(Email A)
                    {
                        return(A.id == TryGetInt);
                    });
                    if (EmailThing.Count() > 0)
                    {
                        var myEmailToDisplay = EmailThing.ElementAt(0);
                        myNewEmail      = new NewEmail();
                        myNewEmail.Body = myEmailToDisplay.Body;
                        myNewEmail.ID   = TryGetInt;
                        myNewEmail.To   = myEmailToDisplay.UserIDTo;
                        var myTask = myUsers.FindByIdAsync(myEmailToDisplay.UserIDFrom);
                        myTask.Wait();
                        myNewEmail.To = myTask.Result.UserName;
                    }
                }
            }

            List <Email> CurrentList = new List <Email>();

            foreach (Email A in MailToMe)
            {
                List <Email> anEmail;
                if (Emails.TryGetValue(A.TimeSent.Date, out anEmail))
                {
                    anEmail.Add(A);
                }
                else
                {
                    anEmail = new List <Email>();
                    anEmail.Add(A);
                    if (Emails.TryAdd(A.TimeSent.Date, anEmail))
                    {
                        LocalRedirect("/Error");
                    }
                }
            }
        }
 public async Task SendTemplatedEmailTest()
 {
     await NewEmail
     .Create("This is a raw email test from the .NET SDK.")
     .To(To, Cc, Bcc)
     .From("*****@*****.**", "*****@*****.**")
     .WithTemplateBody("sample",
                       new Dictionary <string, string>
     {
         { "username", "john.doe" },
         { "firstname", "John" },
         { "lastname", "Doe" },
     },
                       false)
     .SendAsync();
 }
예제 #13
0
        public List <int> VerifyNewEmail()
        {
            NewEmail = NewEmail.Trim().ToLower();

            if (!Helpers.IsProperString(NewEmail))
            {
                return new List <int> {
                           0
                }
            }
            ;

            var errors = new List <int>();

            var lenTest = new Regex(@".{10,50}");

            if (!lenTest.IsMatch(NewEmail))
            {
                errors.Add(1);
            }

            var fmTest = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");

            if (!fmTest.IsMatch(NewEmail) || SharedConstants.InvalidEmailTokens.Any(NewEmail.Contains))
            {
                errors.Add(2);
            }

            if (errors.Count == 0)
            {
                var domain = NewEmail.Split("@")[1];
                if (domain.Split(".").Length > 3)
                {
                    errors.Add(3);
                }
            }

            if (errors.Count == 0 && !NewEmail.Equals(NewEmailConfirm))
            {
                errors.Add(4);
            }

            return(errors);
        }
예제 #14
0
        private static void WriteEmail(EWSInstance instance)
        {
            Console.Clear();
            Console.WriteLine(_newEmailBanner);
            Console.Write("Recipient: ");
            var recipients = Console.ReadLine();

            Console.Write("Subject: ");
            var subject = Console.ReadLine();

            Console.Write("Body: ");
            var body = Console.ReadLine();

            var newMail = new NewEmail(recipients, string.Empty, string.Empty, subject, body);

            var response = newMail.SendNewMail(instance.Service) ? "\nEmail sent successfully.\n" : "\nEmail send failed.  Please try again.\n";

            Console.WriteLine(response);
        }
        public void EnterSignupInformation()
        {
            RemoveEmailPrompt();
            Logger.Info("Entering new user information");
            for (int i = 0; i < NewUserPageElements.Count; i++)
            {
                NewUserPageElements[i].SendKeys(CommonArrays.NewUser[i]);
            }
            Base.Value.EmailAddress       = NameHelper.RandomName(8) + "*****@*****.**";
            Base.Value.EnvironmentCreated = BaseConfiguration.Base;
            NewEmail.SendKeys(Base.Value.EmailAddress);
            NewEmail.Submit();

            Base.NgDriver.IgnoreSynchronization = false;
            //Adding new user email to mongo DB
            Base.Mongo.Insert.NewDocument(Field.NewDocument(Base.Value));
            Base.MongoValuesSet = true;
            Base.IsNewUser      = true;
            Logger.Info("Successfully entered new user information");
        }
        /// <summary>
        /// Returns true if UpdateInstructorRequest instances are equal
        /// </summary>
        /// <param name="other">Instance of UpdateInstructorRequest to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(UpdateInstructorRequest other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     OldEmail == other.OldEmail ||
                     OldEmail != null &&
                     OldEmail.Equals(other.OldEmail)
                     ) &&
                 (
                     NewEmail == other.NewEmail ||
                     NewEmail != null &&
                     NewEmail.Equals(other.NewEmail)
                 ) &&
                 (
                     FirstName == other.FirstName ||
                     FirstName != null &&
                     FirstName.Equals(other.FirstName)
                 ) &&
                 (
                     LastName == other.LastName ||
                     LastName != null &&
                     LastName.Equals(other.LastName)
                 ) &&
                 (
                     IsActive == other.IsActive ||
                     IsActive != null &&
                     IsActive.Equals(other.IsActive)
                 ));
        }
예제 #17
0
        public void OnPostSend()
        {
            //Check if user exists:
            UserData Recipient;
            UserData Writer;

            if (VerifyUsersInfo(out Recipient, out Writer))
            {
                Email email = new Email();
                email.Body       = myNewEmail.Body;
                email.TimeSent   = DateTime.Now;
                email.UserIDTo   = Recipient.Id;
                email.UserIDFrom = Writer.Id;
                myContext.myEmails.Add(email);
                myContext.SaveChanges();
                Error      = "Success!";
                myNewEmail = new NewEmail();
            }
            else
            {
                Error = "Failed to send!";
            }
        }
 public virtual void Attach()
 {
     NewEmail.Get().Message.Attachments.Add(FileInfo.FullName, OlAttachmentType.olByValue);
 }
예제 #19
0
 public object Get(NewEmail request)
 {
     return new ServiceResult<Email>
     {
         Success = true,
         Result = _emailService.New(),
         Errors = new string[] { }
     };
 }
예제 #20
0
        public ActionResult EmailSignUp()
        {
            NewEmail model = new NewEmail();

            return(View("EmailSignUp", model));
        }
예제 #21
0
 public void LoginNewUser()
 {
     NewEmail.SendKeys("*****@*****.**");
     NewParola.SendKeys("pwd123");
     AutentificareButton.Click();
 }
예제 #22
0
        public void SendEmail(Dictionary <string, string> details)
        {
            var newMessage = new NewEmail(details["Sender"], details["CC"], details["BCC"], details["Subject"], details["Body"], _pendingAttachments);

            newMessage.SendNewMail(_service);
        }