-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeedback.aspx.cs
64 lines (51 loc) · 1.72 KB
/
Feedback.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
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.RegularExpressions;
public partial class Feedback : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.User.Identity.IsAuthenticated)
{
Response.Redirect("~/LoginPlease.aspx");
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
string pattern = null;
pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";
if (Regex.IsMatch(TextBox2.Text, pattern))
{
Label4.Text = "Valid Email address ";
}
else
{
Label4.Text = "Not a valid Email address ";
}
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add(TextBox2.Text);
mail.Subject = TextBox1.Text;
mail.Body = TextBox3.Text;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "1181994@");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
Label3.Text = "Email Successfully Sent.";
}
catch (Exception ex)
{
Label3.Text = "Email Failed."+" "+ex.Message;
}
Label3.Visible = true;
Label4.Visible = true;
}
}