-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
773ed8e
commit 7d8e8e4
Showing
15 changed files
with
4,919 additions
and
4,801 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Mail; | ||
using System.Net.Mime; | ||
using System.Web; | ||
using System.Web.UI; | ||
using System.Web.UI.WebControls; | ||
using BO; | ||
|
||
namespace SKDN.Web.Pages | ||
{ | ||
public partial class dang_ky_tham_gia : PageBase | ||
{ | ||
|
||
private static string userName = System.Configuration.ConfigurationManager.AppSettings["MailUserName"]; | ||
private static string password = System.Configuration.ConfigurationManager.AppSettings["MailPassword"]; | ||
private static string smtp = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"]; | ||
protected void Page_Load(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
public static bool SendMail(string recipient, string subject, string body, HttpPostedFile attachmentFilename) | ||
{ | ||
try | ||
{ | ||
SmtpClient smtpClient = new SmtpClient(); | ||
NetworkCredential basicCredential = new NetworkCredential(userName, password); | ||
MailMessage message = new MailMessage(); | ||
MailAddress fromAddress = new MailAddress(userName); | ||
|
||
// setup up the host, increase the timeout to 5 minutes | ||
smtpClient.Host = smtp; | ||
smtpClient.UseDefaultCredentials = true; | ||
smtpClient.Port = 587; | ||
smtpClient.EnableSsl = true; | ||
smtpClient.Credentials = basicCredential; | ||
smtpClient.Timeout = (60 * 5 * 1000); | ||
|
||
message.From = fromAddress; | ||
message.Subject = subject; | ||
message.IsBodyHtml = true; | ||
message.Body = body; | ||
message.To.Add(recipient); | ||
|
||
if (attachmentFilename != null) | ||
{ | ||
Attachment attachment = new Attachment(attachmentFilename.InputStream, attachmentFilename.FileName); | ||
message.Attachments.Add(attachment); | ||
} | ||
|
||
smtpClient.Send(message); | ||
return true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw ex; | ||
} | ||
return false; | ||
|
||
} | ||
|
||
protected void btnNopBai_Click(object sender, EventArgs e) | ||
{ | ||
string subject = txt_group.Value + ":" + txt_Name.Value; | ||
string body = "Bài dự thi Sáng Kiến Đầu Năm của nhóm <b>"+txt_group.Value + ":" + txt_Name.Value+"</b>" + | ||
"<br/> Email:" + txtEmail.Value +"<br/> Tel:"+ txtTel.Value; | ||
if (SendMail(userName, subject, body, txtFile.PostedFile)) | ||
{ | ||
this.Page.RegisterClientScriptBlock("alert", | ||
"<script>alert(\"Bạn đã gửi dự án thành công\"); window.location.href='/'</script>"); | ||
} | ||
else | ||
{ | ||
this.Page.RegisterClientScriptBlock("alert", | ||
"<script>alert(\"Có lỗi xảy ra, bạn vui lòng thử lại sau\"); window.location.href='/'</script>"); | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Mail; | ||
using System.Net.Mime; | ||
using System.Web; | ||
using System.Web.UI; | ||
using System.Web.UI.WebControls; | ||
using BO; | ||
|
||
namespace SKDN.Web.Pages | ||
{ | ||
public partial class dang_ky_tham_gia : PageBase | ||
{ | ||
|
||
private static string userName = System.Configuration.ConfigurationManager.AppSettings["MailUserName"]; | ||
private static string password = System.Configuration.ConfigurationManager.AppSettings["MailPassword"]; | ||
private static string smtp = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"]; | ||
protected void Page_Load(object sender, EventArgs e) | ||
{ | ||
if (!Page.IsPostBack) | ||
{ | ||
DataTable dtAboutUs = SKDNHelper.GetAboutUsPage(1); | ||
if (dtAboutUs != null && dtAboutUs.Rows.Count > 0) | ||
{ | ||
ltrHuongDanDangKy.Text = dtAboutUs.Rows[0]["HuongDanDangKy"].ToString(); | ||
} | ||
} | ||
} | ||
public static bool SendMail(string recipient, string subject, string body, HttpPostedFile attachmentFilename) | ||
{ | ||
try | ||
{ | ||
SmtpClient smtpClient = new SmtpClient(); | ||
NetworkCredential basicCredential = new NetworkCredential(userName, password); | ||
MailMessage message = new MailMessage(); | ||
MailAddress fromAddress = new MailAddress(userName); | ||
|
||
// setup up the host, increase the timeout to 5 minutes | ||
smtpClient.Host = smtp; | ||
smtpClient.UseDefaultCredentials = true; | ||
smtpClient.Port = 587; | ||
smtpClient.EnableSsl = true; | ||
smtpClient.Credentials = basicCredential; | ||
smtpClient.Timeout = (60 * 5 * 1000); | ||
|
||
message.From = fromAddress; | ||
message.Subject = subject; | ||
message.IsBodyHtml = true; | ||
message.Body = body; | ||
message.To.Add(recipient); | ||
|
||
if (attachmentFilename != null) | ||
{ | ||
Attachment attachment = new Attachment(attachmentFilename.InputStream, attachmentFilename.FileName); | ||
message.Attachments.Add(attachment); | ||
} | ||
|
||
smtpClient.Send(message); | ||
return true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
throw ex; | ||
} | ||
return false; | ||
|
||
} | ||
|
||
protected void btnNopBai_Click(object sender, EventArgs e) | ||
{ | ||
string subject = txt_group.Value + ":" + txt_Name.Value; | ||
string body = "Bài dự thi Sáng Kiến Đầu Năm của nhóm <b>"+txt_group.Value + ":" + txt_Name.Value+"</b>" + | ||
"<br/> Email:" + txtEmail.Value +"<br/> Tel:"+ txtTel.Value; | ||
if (SendMail(userName, subject, body, txtFile.PostedFile)) | ||
{ | ||
this.Page.RegisterClientScriptBlock("alert", | ||
"<script>alert(\"Bạn đã gửi dự án thành công\"); window.location.href='/'</script>"); | ||
} | ||
else | ||
{ | ||
this.Page.RegisterClientScriptBlock("alert", | ||
"<script>alert(\"Có lỗi xảy ra, bạn vui lòng thử lại sau\"); window.location.href='/'</script>"); | ||
} | ||
} | ||
} | ||
} |
147 changes: 78 additions & 69 deletions
147
SKDN.Web/SKDN.Web/Pages/dang-ky-tham-gia.aspx.designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.