-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContact.aspx.cs
67 lines (64 loc) · 2.46 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
using GCWebUsabilityTheme;
using IJPReporting.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace IJPReporting
{
public partial class Contact : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListItemCollection subjectsEmail = new ListItemCollection
{
new ListItem("Tech Support", "sweb@justice.gc.ca"),
new ListItem("Web Admin", "ymanaf@justice.gc.ca")
};
subjectDdl.DataSource = subjectsEmail;
subjectDdl.DataBind();
}
}
protected void SendEmail_Click(object sender, EventArgs e)
{
if (this.IsWetValid())
{
Mailer mailer = new Mailer();
string from = emailField.Text;
string name = nameField.Text;
string message = messageField.Text;
string subject = String.Format("Message from {0}", name);
string to = subjectDdl.SelectedValue == "sweb@justice.gc.ca" ? "sweb@justice.gc.ca" : "ymanaf@justice.gc.ca";
bool sent = mailer.SendMail(subject, message, from, to) == 1;
if (sent)
{
wetAlert.AlertType = WetControls.Controls.WetAlert.ALERT_TYPE.Success;
wetAlert.Title = "Nous avons recus votre message!";
wetAlert.Visible = true;
upAlert.Update();
emailField.Text = String.Empty;
nameField.Text = String.Empty;
messageField.Text = String.Empty;
subjectDdl.ClearSelection();
}
else
{
wetAlert.AlertType = WetControls.Controls.WetAlert.ALERT_TYPE.Danger;
wetAlert.Title = "Un problème est survenu, veuillez ressayer plus tard!";
wetAlert.Visible = true;
upAlert.Update();
}
} else
{
wetAlert.AlertType = WetControls.Controls.WetAlert.ALERT_TYPE.Danger;
wetAlert.Title = "Un problème est survenu, veuillez ressayer plus tard!";
wetAlert.Visible = true;
upAlert.Update();
}
}
}
}