using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Text;


public partial class enquiry_form : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
        
        }
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
                try
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<h3>You Have Receieved enquiry</h3>");
            sb.Append("<table> <tr><td><b>Name:</b> " + txtName.Text + "</td><td></td><td></td></tr>");
            sb.Append("<tr><td><b>From:</b> " + txtSource.Text + "</td><td><b>To</b> " + txtDestination.Text + "</td><td></td></tr>");
            sb.Append("<tr><td><b>Contact No:</b> " + txtContact.Text + "</td><td></td><td></td></tr>");
            sb.Append("<tr><td><b>Email</b> " + txtEmail.Text + "</td><td></td><td></td></tr>");
            sb.Append("<tr><td><b>Date:</b> " + txtDate.Text + "</td><td></td><td></td></tr>");
            sb.Append("<tr><td><b>Message</b></td><td></td><td></td></tr>");
            sb.Append("<tr><td colspan=" + 3 + ">" + txtMessage.Text + "</td></tr>");
            sb.Append("</table>");

            MailMessage mailMessage = new MailMessage("enquiry@a1packersandmovers.com", "ankush@a1packersandmovers.com");
            mailMessage.Body = sb.ToString();
            SmtpClient smtpClient = new SmtpClient("mail.a1packersandmovers.com", 25);
            smtpClient.Credentials = new System.Net.NetworkCredential()
            {
                UserName = "enquiry@a1packersandmovers.com",
                Password = "Ankush_123"

            };
            mailMessage.IsBodyHtml = true;
            //smtpClient.EnableSsl = true;
            smtpClient.Send(mailMessage);

            lblMessage.ForeColor = System.Drawing.Color.Green;
            lblMessage.Text = "Your Message Has been sent...";
        }
        catch (Exception)
        {

            lblMessage.ForeColor = System.Drawing.Color.Red;
            lblMessage.Text = "Message Sending Failed...";
        }
       

    }

    
}