/// <summary> /// Raised when the page is loaded /// </summary> /// <param name="sender">Element which raised the event.</param> /// <param name="e">Event arguments</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ICampusReader client = new CampusReaderClient(); listCampus.DataSource = client.GetCampuses(); listCampus.DataBind(); } }
/// <summary> /// Raised when the page is loaded /// </summary> /// <param name="sender">Element which raised the event.</param> /// <param name="e">Event arguments</param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ICampusReader client = new CampusReaderClient(); listCampus.DataSource = client.GetCampuses(); listCampus.DataBind(); } }
private void SendEmail() { ICampusReader client = new CampusReaderClient(); ListItem selectedIdCampus = listCampus.SelectedItem; int idCampus = int.Parse(selectedIdCampus.Value); Campus campus = client.GetCampus(idCampus); using (MailMessage mail = new MailMessage()) { MailAddress sender = new MailAddress(txtEmail.Text); mail.From = sender; MailAddress reciever = new MailAddress(campus.ContactEmail); mail.To.Add(reciever); mail.Subject = EmailRessources.Title; mail.IsBodyHtml = true; mail.Body = string.Format(EmailRessources.Body, txtFirstName.Text, txtSurname.Text, Regex.Replace(txtEmail.Text, "<.*?>", string.Empty), txtEmail.Text); mail.Priority = MailPriority.Normal; SmtpClient smtp = new SmtpClient { Credentials = new NetworkCredential(EmailRessources.Login, EmailRessources.Password), Host = EmailRessources.Host, Port = int.Parse(EmailRessources.Port), DeliveryMethod = SmtpDeliveryMethod.Network, EnableSsl = true }; smtp.Send(mail); smtp.Dispose(); } txtSurname.Text = string.Empty; txtFirstName.Text = string.Empty; txtEmail.Text = string.Empty; txtMessage.Text = string.Empty; }
private void SendEmail() { ICampusReader client = new CampusReaderClient(); ListItem selectedIdCampus = listCampus.SelectedItem; int idCampus = int.Parse(selectedIdCampus.Value); Campus campus = client.GetCampus(idCampus); using (MailMessage mail = new MailMessage()) { MailAddress sender = new MailAddress(txtEmail.Text); mail.From = sender; MailAddress reciever = new MailAddress(campus.ContactEmail); mail.To.Add(reciever); mail.Subject = EmailRessources.Title; mail.IsBodyHtml = true; mail.Body = string.Format(EmailRessources.Body, txtFirstName.Text, txtSurname.Text, Regex.Replace(txtEmail.Text, "<.*?>", string.Empty), txtEmail.Text); mail.Priority = MailPriority.Normal; SmtpClient smtp = new SmtpClient { Credentials = new NetworkCredential(EmailRessources.Login, EmailRessources.Password), Host = EmailRessources.Host, Port = int.Parse(EmailRessources.Port), DeliveryMethod = SmtpDeliveryMethod.Network, EnableSsl = true }; smtp.Send(mail); smtp.Dispose(); } txtSurname.Text = string.Empty; txtFirstName.Text = string.Empty; txtEmail.Text = string.Empty; txtMessage.Text = string.Empty; }