-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSupport.cs
65 lines (58 loc) · 2.31 KB
/
Support.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Kursov
{
public partial class Support : Form
{
public Support()
{
InitializeComponent();
}
public SqlConnection sqlcon = new SqlConnection(@"Data Source=LAPTOP-8RIM0556\SQLEXPRESS;Initial Catalog=Tennis;Integrated Security=True");
public string email = "";
private void Button1_Click(object sender, EventArgs e)
{
sqlcon.Open();
string query = @"Select Email_Profile from Person_Profile where ID_Person ='"+ForAnalitics.ID+"'";
SqlCommand com = new SqlCommand(query, sqlcon);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read()) email = reader[0].ToString();
reader.Close();
sqlcon.Close();
// отправитель - устанавливаем адрес и отображаемое в письме имя
MailAddress from = new MailAddress("[email protected]", "Statistics");
// кому отправляем
MailAddress to = new MailAddress(email);
// создаем объект сообщения
MailMessage m = new MailMessage(from, to);
// тема письма
m.Subject = "Кажется, вы забыли пароль!";
// текст письма
m.Body = textBox1.Text;
// письмо представляет код html
m.IsBodyHtml = true;
// адрес smtp-сервера и порт, с которого будем отправлять письмо
SmtpClient smtp = new SmtpClient("smtp.mail.ru", 587);
// логин и пароль
smtp.Credentials = new NetworkCredential("[email protected]", "Nikita13062000");
smtp.EnableSsl = true;
smtp.Send(m);
}
private void Support_Load(object sender, EventArgs e)
{
}
private void Label2_Click(object sender, EventArgs e)
{
}
}
}