-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssetC.aspx.cs
56 lines (50 loc) · 1.96 KB
/
AssetC.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
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Mail;
using System.Text;
public partial class AssetC : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnReg_Click(object sender, EventArgs e)
{
Response.Redirect("Regist.aspx");
}
protected void SendEmail(object sender, EventArgs e)
{
var email = "[email protected]";
var pass = "sairam009";
try
{
using (MailMessage mm = new MailMessage(email, "[email protected]"))
{
mm.Subject ="Query regarding the website";
mm.Body ="Comments";
//if (fuAttachment.HasFile)
//{
// string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
// mm.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
//}
mm.IsBodyHtml = false;
mm.BodyEncoding = Encoding.Default;
mm.Priority = MailPriority.High;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential(email, pass);
smtp.UseDefaultCredentials = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = NetworkCred;
smtp.ServicePoint.MaxIdleTime = 0;
smtp.ServicePoint.SetTcpKeepAlive(true, 2000, 2000);
smtp.Port = 587;
smtp.Send(mm);
ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Message has been sent successfully.');", true);
}
}
catch (Exception ex)
{ ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email could not be sent');", true); }
}
}