-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathContact.aspx.cs
75 lines (66 loc) · 2.37 KB
/
Contact.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txt_name.Focus();
if (!IsPostBack)
{
panel_office_address.Visible = true;
panel_message_me.Visible = false;
btn_office_address.BackColor = System.Drawing.Color.Green;
}
}
protected void btn_office_address_Click(object sender, EventArgs e)
{
panel_office_address.Visible = true;
panel_message_me.Visible = false;
btn_office_address.BackColor = System.Drawing.Color.Green;
btn_mail_us.BackColor = System.Drawing.Color.White;
}
protected void btn_mail_us_Click(object sender, EventArgs e)
{
panel_message_me.Visible = true;
panel_office_address.Visible = false;
btn_mail_us.BackColor = System.Drawing.Color.Green;
btn_office_address.BackColor = System.Drawing.Color.White;
lbl_msg.Text = " ";
}
protected void btn_messge_submit_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress(txt_email.Text);
msg.To.Add("aalifkhan7@gmail.com");
msg.Subject = "Our report of many thing";
msg.Body = "Name " + txt_name.Text + "<br/>" + "Phone Number : " + txt_number.Text + "<br/>" + "Comments " + txt_comments + "<br/>";
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential();
smtp.Send(msg);
lbl_msg.Text = "Thank you for your support";
lbl_msg.ForeColor = System.Drawing.Color.Green;
}
else
{
lbl_msg.Text = "Try again";
lbl_msg.ForeColor = System.Drawing.Color.Red;
}
}
catch(Exception ex)
{
lbl_msg.Text = "Try again <br/ >" + ex.Message;
lbl_msg.ForeColor = System.Drawing.Color.Red;
}
}
}