using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using System.Net;
using System.Drawing;
using System.IO;
public partial class FeedbackMultiple_ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private void EmailFeedback()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress(txtEmail.Text.Trim());
mail.To.Add("anwar@csharpexample.com");
//set the content
mail.Subject = "Enquiry Form";
//get list item using foreach loop
string Education = string.Empty;
foreach (ListItem item in chkEducation.Items)
{
if (item.Selected == true)
{
Education += item.Value + "<br>";
}
}
//Body to be displayed
mail.Body = "<h2>" + "Enquiry from " + " " + txtName.Text + "</h2>" + "<br><br>" +
"Subject : " + txtSubject.Text + "<br>" +
"Email : " + txtEmail.Text.Trim() + "<br>" +
"InQuiry : " + txtInquiry.Text.Trim() + "<br>" +
"Education: " + Education.ToString() + "<br>" +
"Thank You";
mail.IsBodyHtml = true;
// smtp settings
SmtpClient smtp = new SmtpClient("mail.csharpexample.com");
NetworkCredential SMTPUserInfo = new NetworkCredential("anwar@csharpexample.com", "Abcd123@fg5");
smtp.Credentials = SMTPUserInfo;
smtp.Send(mail);
}
private void Clear()
{
txtName.Text = string.Empty;
txtSubject.Text = string.Empty;
txtEmail.Text = string.Empty;
txtInquiry.Text = string.Empty;
chkEducation.ClearSelection();
}
protected void btnSubmit_Click1(object sender, EventArgs e)
{
EmailFeedback();
lblMsg.ForeColor = Color.Green;
Clear();
lblMsg.Text = "Thank You for Your Inquiry";
}
}