Esempio n. 1
0
 protected void LinkButtonSend_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         var contactRequest = new ContactRequest {
             Name = TextBoxName.Text,
             Email = TextBoxEmail.Text,
             Phone = TextBoxPhone.Text,
             Message = TextBoxMessage.Text,
             Interests = String.Join(", ", CheckBoxListInterests.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray()) };
         contactRequest.Save();
         var emailService = new EmailService(EmailService.form.contact);
         var notificationMessage = emailService.mailMessage;
         notificationMessage.Subject = "New contact request";
         notificationMessage.Body = String.Format("Name: {0}\n\nEmail: {1}\n\nPhone: {2}\n\nMessage:\n{3}\n\nInterests: {4}\n\n",
             TextBoxName.Text,
             TextBoxEmail.Text,
             TextBoxPhone.Text,
             TextBoxMessage.Text,
             String.Join(", ", CheckBoxListInterests.Items.Cast<ListItem>().Where(item => item.Selected).Select(item => item.Value).ToArray()));
         emailService.sendMessage(notificationMessage);
         MultiViewContactRequest.SetActiveView(ViewResponse);
     }
 }