/// <summary> /// Creates the email contact. /// </summary> /// <param name="emailAddress">The email address.</param> /// <param name="displayName">The display name.</param> /// <returns></returns> private static EmailContact CreateEmailContact(string emailAddress, string displayName) { if (emailAddress == null) { return(null); } ///// // Create a new email contact. ///// var emailContact = new EmailContact( ); if (displayName != null) { emailContact.Name = displayName; emailContact.EmailContactDisplayName = displayName; } else { emailContact.Name = emailAddress; } emailContact.Name = emailAddress; return(emailContact); }
public async Task <Response> SaveResident(ResidentRequest residentResquest) { var residentId = GetMaterializeResidentId(residentResquest.BlockNumber, residentResquest.HouseNumber); var getResidentDuplicated = _securityPaymentContext.ResidentInformation.ToList() .Find(x => x.ResidentInformationId == residentId); if (getResidentDuplicated == null) { ControlTransactionFields transactionInfo = TransactionInfo.GetTransactionInfo(); IDbContextTransaction transaction = _securityPaymentContext.Database.BeginTransaction(); ResidentInformation residentInformation = MaterializeGeneralResidentInformation(residentResquest, residentId, transactionInfo); PhoneContact phoneContact = MaterializeContactInformation(residentResquest, residentId, transactionInfo); EmailContact emailContact = MaterializeEmailContact(residentResquest, residentId, transactionInfo); HouseInformation houseInformation = MaterializeHouseInformation(residentResquest, residentId, transactionInfo); await _securityPaymentContext.AddAsync <ResidentInformation>(residentInformation); await _securityPaymentContext.AddAsync <PhoneContact>(phoneContact); await _securityPaymentContext.AddAsync <EmailContact>(emailContact); await _securityPaymentContext.AddAsync <HouseInformation>(houseInformation); await _securityPaymentContext.SaveChangesAsync(); transaction.Commit(); return(new Response { Data = residentInformation }); } return(new Response { Message = "Failed, the resident already exist!" }); }
public object Parse(string value, object argument) { var contacts = new List <EmailContact>(); var index = value.IndexOf(Characters.Colon); var sub = value.Substring(index + 1); var items = sub.Split(Characters.Comma); foreach (var item in items) { EmailContact contact; var emailMatch = Regex.Match(item, RegexPatterns.EmailBracketPattern); if (emailMatch.Success) { var email = emailMatch.Value.TrimAny(1); var cropped = item.Replace(emailMatch.Value, string.Empty); var name = cropped.Trim(); name = name.TrimQuotes(); contact = new EmailContact(name, email); } else { contact = new EmailContact(value.TrimQuotes()); } contacts.Add(contact); } return(contacts); }
public async Task SendBulkEmailToAllDeacons(AnnouncementViewModel viewModel, string username) { var user = _unitOfWork.AppUserRepository.FindUserByEmail(username); var deacons = _unitOfWork.AppUserRepository.FindUsersByRole(enums.AppUserRole.Deacon); var emailContacts = new List <EmailContact>(); var emailClient = new EmailWrapperClient(); var email = new EmailContact { FromEmailAddress = user.EmailAddress, Subject = viewModel.Title, PlainTextBody = HtmlRemoval.ConvertHtmlToPlainText(viewModel.AnnouncementHtml), HtmlBody = viewModel.AnnouncementHtml }; foreach (var deacon in deacons) { emailContacts.Add(new EmailContact { ToEmailAddress = deacon.EmailAddress, ReceiverName = deacon.FullName }); } var response = await emailClient.SendMultipleEmailsAsync(emailContacts, email); }
public ActionResult SendEmail(int memberId) { var emailContact = new EmailContact(); var user = unitOfWork.AppUserRepository.FindUserById(User.Identity.GetUserId()); var member = unitOfWork.MemberRepository.FindMemberById(memberId); emailContact.FromEmailAddress = user.Email; emailContact.ToEmailAddress = member.EmailAddress; emailContact.MemberId = memberId; emailContact.SenderName = user.FullName; emailContact.DateSent = DateTime.Now; emailContact.PlainTextBody = string.Empty; emailContact.ReceiverName = $"{member.FirstName} {member.LastName}"; var emailViewModel = new EmailViewModel { EmailContact = emailContact, Bulk = false, IsTesting = bool.Parse(ConfigurationManager.AppSettings["TestSendGrid"]) }; emailViewModel.StatusNotification = new NotificationViewModel(); return(View(emailViewModel)); }
public ActionResult Contact(EmailContact model) { if (ModelState.IsValid) { var body = "Name: {0} <br /> Email: {1} <br /> Phone: {2} <br /> Message: {3} <br /> Contact Type Phone: {4} <br /> Contact Type Email: {5}"; var message = new SendGridMessage(); message.AddTo("*****@*****.**"); message.AddTo("*****@*****.**"); message.AddTo("*****@*****.**"); // replace with valid value message.From = new MailAddress("*****@*****.**"); // replace with valid value message.Subject = "Totes 2 Go Contact"; message.Html = string.Format(body, model.Name, model.Email, model.Phone, model.Message, model.PhoneCheck, model.EmailCheck); //Azure credentials var username = "******"; var pswd = "Cg090482?"; // variable to store azure credentials var credentials = new NetworkCredential(username, pswd); // Create an Web transport for sending email. var transportWeb = new Web(credentials); // Send the email, which returns an awaitable task. transportWeb.DeliverAsync(message); ModelState.Clear(); //clears form when page reload //Response.Redirect(Request.Url.AbsolutePath); //redirects page to index page, prevents double return(RedirectToAction("ReturnSender", "Home", new { model.Name, model.Email, model.Phone, model.Message })); } return(View(model)); }
public ActionResult BulkEmail(BulkContactViewModel viewModel) { if (viewModel.Members.Count == 0) { return(RedirectToAction("ContactSelected")); } var user = unitOfWork.AppUserRepository.FindUserByEmail(User.Identity.Name); var emailContact = new EmailContact { FromEmailAddress = user.Email, ToEmailAddress = "*****@*****.**", SenderName = user.FullName, DateSent = DateTime.Now, }; var emailViewModel = new EmailViewModel { EmailContact = emailContact, Bulk = true, Members = viewModel.Members }; TempData["EmailViewModel"] = emailViewModel; return(RedirectToAction("SendBulkEmail", "Email")); }
public object Parse(string value, object argument) { var contacts = new List<EmailContact>(); var index = value.IndexOf(Characters.Colon); var sub = value.Substring(index + 1); var items = sub.Split(Characters.Comma); foreach (var item in items) { EmailContact contact; var emailMatch = Regex.Match(item, RegexPatterns.EmailBracketPattern); if (emailMatch.Success) { var email = emailMatch.Value.TrimAny(1); var cropped = item.Replace(emailMatch.Value, string.Empty); var name = cropped.Trim(); name = name.TrimQuotes(); contact = new EmailContact(name, email); } else { contact = new EmailContact(value.TrimQuotes()); } contacts.Add(contact); } return contacts; }
public EmailMessage(EmailContact from, EmailContact to, string subject, EmailContent content) : this(from : from, to : new EmailContact[] { Guard.Null(nameof(to), to) }, subject : subject, contents : new EmailContent[] { Guard.Null(nameof(content), content) }) { }
public void SendEmail(EmailContact to, EmailAccount from, string subject, string message, List <Discover.Emailing.EmailAttachment> attachments, bool digitallySign, bool encrypt, string batchId) { List <EmailContact> tos = new List <EmailContact>(); tos.Add(to); SendEmail(tos, from, subject, message, attachments, digitallySign, encrypt, batchId); }
public void makeReservation(EmailContact ec) { System.Diagnostics.Debug.WriteLine("tukaaaaaaaaaaaaaaaaaaaa"); var body = "<html><body style='background-color:orange; font-family: Arial,sans-serif; text-align:center;'><h1>Reservation</h1><br><p>A reservation was made for your restaurant, {0}, at {1} for {2} people. Please contact {3} to confirm reservation.</p><p>Vizi team</p></body><html>"; var message = new MailMessage(); string userId = User.Identity.GetUserId(); ApplicationUser au = db.Users.Find(userId); var restaurant = (from r in db.Restaurants where r.Id == ec.RestaurantId select r).FirstOrDefault(); var manager = (from r in db.Users where r.Id == restaurant.ManagerId select r).FirstOrDefault(); System.Diagnostics.Debug.WriteLine("tukaaaaaaaaaaaaaaaaaaaa"); message.To.Add(new MailAddress(manager.Email)); message.From = new MailAddress("*****@*****.**", "noreply"); message.Subject = "Reservation for " + restaurant.Name; message.Body = string.Format(body, restaurant.Name, ec.Hour, ec.People, ec.PhoneNumber); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", Password = "******" }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.Send(message); } }
public FormLayoutContactInfo() { Email = new EmailContact(); Phone = new PhoneContact(); SMS = new SMSContact(); InstantMessenger = new InstantMessengerContact(); PostalService = new PostalServiceContact(); }
public void CopyTo_Should_Throw_ArgumentNullException_When_Copy_Target_Is_Null() { Contact contact = new EmailContact(); Action act = () => contact.CopyTo(null); act.Should().Throw <ArgumentNullException>(); }
public FormLayoutContactInfo() { Email = new EmailContact(); Phone = new PhoneContact(); SMS = new SMSContact(); InstantMessenger = new InstantMessengerContact(); PostalService = new PostalServiceContact(); }
public void CopyTo_Should_Throw_ArgumentException_When_Copy_Target_Is_Not_The_Same_Type_As_Copy_Origin() { Contact emailContact = new EmailContact(); Contact phoneContact = new PhoneContact(); Action act = () => emailContact.CopyTo(phoneContact); act.Should().Throw <ArgumentException>().WithMessage("Copy origin and copy target must be of the same type."); }
public override void Parse(SmtpResponseReader reader) { while (!reader.IsLast) { var contact = EmailContact.Parse(reader.CurrentLine); _matches.Add(contact); } Evaluate(reader); }
public void Address_Property_Should_Throw_ArgumentException_When_Set_To_An_Invalid_Email_Address() { EmailContact emailContact = new EmailContact { Address = "*****@*****.**" }; Action act = () => emailContact.Address = "invalidmail"; act.Should().Throw <ArgumentException>().WithMessage("'invalidmail' is not a valid email!"); }
public void Address_Property_Should_Throw_ArgumentException_When_Set_To_Null() { EmailContact emailContact = new EmailContact { Address = "*****@*****.**" }; Action act = () => emailContact.Address = null; act.Should().Throw <ArgumentException>().WithMessage("*Address cannot be null or empty.*"); }
public void EmptyEmailContactIsNotValid() { // Arrange EmailContact emailContact = new EmailContact(""); // Act bool isValid = emailContact.IsValid; // Assert Assert.IsFalse(isValid); }
public void FromBytes(byte[] bytes) { System.IO.BinaryReader reader = new System.IO.BinaryReader(new System.IO.MemoryStream(bytes)); Id = readString(reader); Name = readString(reader); short size = reader.ReadInt16(); log("Photo size == " + size); if (size > 0) { byte[] photo = reader.ReadBytes((int)size); PhotoTexture = new Texture2D(2, 2); PhotoTexture.LoadImage(photo); } size = reader.ReadInt16(); log("Phones size == " + size); if (size > 0) { for (int i = 0; i < size; i++) { PhoneContact pc = new PhoneContact(); pc.Number = readString(reader); pc.Type = readString(reader); Phones.Add(pc); } } size = reader.ReadInt16(); log("Emails size == " + size); if (size > 0) { for (int i = 0; i < size; i++) { EmailContact ec = new EmailContact(); ec.Address = readString(reader); ec.Type = readString(reader); Emails.Add(ec); } } size = reader.ReadInt16(); log("Connections size == " + size); if (size > 0) { for (int i = 0; i < size; i++) { string connection = readString(reader); Connections.Add(connection); } } }
public void EmailContactWithInValidEmailAddressIsNotValid() { // Arrange EmailContact emailContact = new EmailContact("testexample.com"); // Act bool isValid = emailContact.IsValid; // Assert Assert.IsFalse(isValid); }
public JsonResult UpdateMail(string xemail) { EmailContact email = new EmailContact(); email.Email = xemail; var result = new EmailContactDAO().UpdateMail(email); return(Json(new { status = result })); }
public void CopyTo_Should_Copy_EmailContact_Address_Property() { EmailContact emailContact = new EmailContact { Address = "*****@*****.**" }; EmailContact emailContactCopyTarget = new EmailContact { Address = "*****@*****.**" }; emailContact.CopyTo(emailContactCopyTarget); emailContactCopyTarget.Address.Should().Be(emailContact.Address); }
public void CopyTo_Should_Copy_Contact_Person_Property() { Contact contact = new EmailContact { Address = "*****@*****.**", Person = new Person { Name = "personName" } }; Contact copyTargetContact = new EmailContact(); contact.CopyTo(copyTargetContact); copyTargetContact.Person.Should().Be(contact.Person); }
public void CopyTo_Should_Copy_Contact_Name_Property() { Contact contact = new EmailContact { Address = "*****@*****.**", Name = "EmailContactName" }; Contact copyTargetContact = new EmailContact { Name = "CopyTargetEmailContactName" }; contact.CopyTo(copyTargetContact); copyTargetContact.Name.Should().Be(contact.Name); }
public ActionResult Contact(EmailContact emailContact) { // Example of // Send Email notification bool result = NotificationService.SendContactUsEmail(emailContact); if (result) { return(RedirectToAction("Contact")); } return(View(emailContact)); }
public EmailContact FindByEmailAddrress(string email) { EmailContact result = null; using (PersonsDBEntities DC = conn.GetContext()) { //-- SELECT * FROM vPhoneList WHERE PhobeID = phoneID result = (from r in DC.EmailContacts where r.EmailAddrress == email select r).FirstOrDefault(); } return(result); }
private List <ResidentRequest> GetResidentsCompleteInformation(List <ResidentInformation> getAllResidents) { var residentsCompleteInformationList = new List <ResidentRequest>(); foreach (var resident in getAllResidents) { HouseInformation houseInformation = GetHouseInformationByResidentId(resident.ResidentInformationId); EmailContact emailContact = GetEmailContactByResidentId(resident.ResidentInformationId); PhoneContact phoneContact = GetPhoneContactByResidentId(resident.ResidentInformationId); var getResidentMaterializeObject = GetResidentMaterializeObject(resident, houseInformation, emailContact, phoneContact); residentsCompleteInformationList.Add(getResidentMaterializeObject); } return(residentsCompleteInformationList); }
public EmailMessage(EmailContact from, EmailContact[] to, string subject, EmailContent[] contents) { Guard.Null(nameof(to), to); Guard.NoItems(nameof(to), to); Guard.NullItem(nameof(to), to); Guard.Null(nameof(contents), contents); Guard.NoItems(nameof(contents), contents); Guard.NullItem(nameof(contents), contents); this.From = Guard.Null(nameof(from), from); this.To = to; this.Subject = Guard.NullOrWhiteSpace(nameof(subject), subject); this.Contents = contents; }
/// <summary> /// Sends a single email asynchronously. /// </summary> /// <param name="email">The email.</param> /// <returns></returns> public async Task <Response> SendSingleEmailAsync(EmailContact email) { var from = new EmailAddress(email.FromEmailAddress, email.SenderName); var to = new EmailAddress(email.ToEmailAddress, email.ReceiverName); var emailToSend = MailHelper.CreateSingleEmail( from, to, email.Subject, email.PlainTextBody, email.HtmlBody); return(await _client.SendEmailAsync(emailToSend)); }
private EmailContact GetPassAlongEmail(ContactRecord record, CCGAppUser user, UnitOfWork db, StringBuilder sb) { // // ***TEST ONLY*** // I've replace the user's email address with // literal string for testing only // string toEmailAddress = "*****@*****.**"; //string toEmailAddress = pastor.Email; // var email = new EmailContact(); email.SenderName = user.FullName; email.FromEmailAddress = user.Email; email.ToEmailAddress = toEmailAddress; email.Subject = $"From Deacon {user.FullName}"; // For testing, the email to the pastor is formatted // like this: // Subject: From Deacon Paul Bolden // Body: // [Pass along message from deacon] // [Contact record subject] // [Contact record comments if not private] sb.Append(record.PassAlongComments); sb.Append(Environment.NewLine + Environment.NewLine); sb.Append(record.Subject); sb.Append(Environment.NewLine + Environment.NewLine); if (!record.Private) { sb.Append(record.Comments); } // record.PassAlongComments; // What do we want to email message to the pastor to say? // Should the subject be the same as the contact record // or should it be something like "From Deacon Paul"? sb.Clear(); return(email); }
public async Task <bool> AddContactAsync(string name, string email, string title, string content) { var emailContact = new EmailContact { Name = name, Email = email, Title = title, Content = content, }; await this.emailContactRepository.AddAsync(emailContact); await this.emailContactRepository.SaveChangesAsync(); return(true); }
private ResponseData SendEmail(EmailContact contact) { try { const string SERVER = "relay-hosting.secureserver.net"; SmtpClient client = new SmtpClient(SERVER); MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailContactOrigin"], ConfigurationManager.AppSettings["EmailContactReceiver"]); mail.Priority = MailPriority.High; mail.Subject = "A Customer has requested to be contacted regarding: " + contact.inputService; mail.IsBodyHtml = true; StringBuilder sb = new StringBuilder(); sb.Append("<p><strong>Customer Name: </strong>" + contact.inputName + "</p>"); sb.Append("<p><strong>Service Needed: </strong>" + contact.inputService + "</p>"); sb.Append("<p><strong>Message: </strong></p>"); sb.AppendLine("<pre style='font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: black;'>" + contact.inputMessage + "</pre> <br />"); sb.Append("<span style='font-size:14px;'>Respond to customer: Email - " + contact.inputEmail + " | Phone - " + contact.inputPhone + "</span>"); mail.Body = sb.ToString(); client.Send(mail); return new ResponseData() { success = true, message = "Message successfully sent!" }; } catch (Exception e) { string errorMessage = string.Format("Error in method: {0} | Exception type: {1} | Message: {2} | StackTrace: {3}", System.Reflection.MethodBase.GetCurrentMethod(), e.GetType(), e.Message, e.StackTrace); //Log.Error(errorMessage); return new ResponseData() { success = false, message = errorMessage }; } }
public ResponseData PostContact(EmailContact contact) { var response = SendEmail(contact); return response; }
public static void Execute() { var connection = new ActiveDirectoryConnection(); var service = new ExchangeAddressListService(connection); var ds = service.GetGlobalAddressLists().Where(a => a.Name == "symmetryinvestments.com - GAL"); foreach (var addressList in ds) { var knownEmployees = Employee.Employees(e => e.Attributes.ContainsKey("ExchangeIdentifier")); Console.Out.WriteLine("addressList.Name = {0}", addressList.Name); foreach (var searchResult in addressList.GetMembers()) { if (searchResult.Properties.Contains("grouptype") || !searchResult.Properties.Contains("sn") || searchResult.Properties.Contains("targetaddress") || (searchResult.Properties.Contains("mailnickname") && searchResult.Properties["displayname"][0].Equals(searchResult.Properties["mailnickname"][0])) || (searchResult.Properties.Contains("mailnickname") && searchResult.Properties["name"][0].Equals(searchResult.Properties["mailnickname"][0]))) continue; // Identifier string objectId =System.Convert.ToBase64String( (byte[])searchResult.Properties["objectsid"][0]); // NT User NAme string ntName = searchResult.Properties["samaccountname"][0].ToString(); // Fund or create the empliyee Employee employee = knownEmployees.FirstOrDefault(e => e.Attributes.ContainsKey("ExchangeIdentifier") && e.Attributes["ExchangeIdentifier"].Equals(objectId)) ?? new Employee(ntName) { Active = true, SecurityIdentifier = string.Format("OPTIONS-IT\\{0}", ntName) }; // Set the full name employee.FullName = searchResult.Properties["name"][0].ToString(); // Set the Exchange Identifier if it doesn't already exist if (!employee.Attributes.ContainsKey("ExchangeIdentifier")) employee.Attributes.Add("ExchangeIdentifier", objectId); // Work Email EmailContact ec = (EmailContact)employee.ContactCard.FirstOrDefault( f => f.ContactDetailType == eContactDetailType.Email && f.DisplayName.Equals("Work Email")); if (ec == null) { ec = new EmailContact() { DisplayName = "Work Email", Primary = true }; employee.ContactCard.Add(ec); } if(searchResult.Properties.Contains("mail")) ec.EmailAddress = searchResult.Properties["mail"][0].ToString(); // Telephone Number UpdateTelephoneContact(employee, eTelephoneContactType.Office, searchResult, "telephonenumber", "Office"); UpdateTelephoneContact(employee, eTelephoneContactType.Office, searchResult, "othertelephone", "Other"); UpdateTelephoneContact(employee, eTelephoneContactType.Mobile, searchResult, "mobile", "Mobile"); UpdateTelephoneContact(employee, eTelephoneContactType.Office, searchResult, "homephone", "Misc"); if (string.IsNullOrEmpty(employee.Title)) employee.Title = string.Empty; employee.Save(); } } }