Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.IO;
- using System.Threading.Tasks;
- using System.Net.Mail;
- namespace kursovaya
- {
- class Program
- {
- class user_data
- {
- // использовать getter-setter для дальнейшего кода
- private string my_mail;
- private string some_mail;
- private string password;
- private string nickname;
- private string headline;
- public string UserMail
- {
- get { return my_mail; }
- set
- {
- if (value == "" | value == " ")
- {
- Console.WriteLine("Такое значение недопустимо при заполнении поля 'почта'. Значение сброшено до стандартного ");
- value = "obechekopm@gmail.com";
- my_mail = value;
- }
- else
- {
- my_mail = value;
- }
- }
- }
- public string SomeMail
- {
- get { return some_mail; }
- set {
- if (value == "" | value == " ")
- {
- Console.WriteLine("Такое значение недопустимо при заполнении поля 'почта'. Значение сброшено до стандартного ");
- value = "obechekopm@gmail.com";
- some_mail = value;
- }
- else
- {
- some_mail = value;
- }
- }
- }
- public string Password
- {
- get { return password; }
- set { password = value; }
- }
- public string Nickname
- {
- get { return nickname; }
- set { nickname = value; }
- }
- public string Headline
- {
- get { return headline; }
- set { headline = value; }
- }
- public void Print()
- {
- Console.WriteLine("Письмо успешно отправлено");
- }
- }
- class Sendmail : user_data
- {
- public Sendmail()
- {
- }
- public Sendmail(string email_address, string pass)
- {
- string my_mail = email_address;
- string nickname = "Anonymous";
- string password = pass;
- string headline = "Testing";
- MailAddress from = new MailAddress(my_mail, nickname);
- MailAddress to = new MailAddress(my_mail);
- MailMessage mess = new MailMessage(from, to);
- mess.Subject = headline;
- mess.Body = "<h2> Письмо-тест </h2>";
- mess.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
- smtp.Credentials = new NetworkCredential(my_mail, password);
- smtp.EnableSsl = true;
- smtp.Send(mess);
- Console.Read();
- }
- public Sendmail(
- string mail_1,
- string mail_2,
- string user_pass,
- string for_headline
- )
- {
- string my_mail = mail_1;
- string nickname = "Anonymous";
- string some_mail = mail_2;
- string password = user_pass;
- string headline = for_headline;
- MailAddress from = new MailAddress(my_mail, nickname);
- MailAddress to = new MailAddress(some_mail);
- MailMessage mess = new MailMessage(from, to);
- mess.Subject = headline;
- mess.Body = "<h2> Письмо-тест </h2>";
- mess.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
- smtp.Credentials = new NetworkCredential(my_mail, password);
- smtp.EnableSsl = true;
- smtp.Send(mess);
- Console.Read();
- }
- public Sendmail(
- string username,
- string mail_1,
- string mail_2,
- string user_pass,
- string for_headline
- )
- {
- string my_mail = mail_1;
- string nickname = username;
- string some_mail = mail_2;
- string password = user_pass;
- string headline = for_headline;
- MailAddress from = new MailAddress(my_mail, nickname);
- MailAddress to = new MailAddress(some_mail);
- MailMessage mess = new MailMessage(from, to);
- mess.Subject = headline;
- mess.Body = "<h2> Письмо-тест </h2>";
- mess.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
- smtp.Credentials = new NetworkCredential(my_mail, password);
- smtp.EnableSsl = true;
- smtp.Send(mess);
- Console.Read();
- }
- }
- static void Main(string[] args)
- {
- Sendmail someone_mail = new Sendmail();
- someone_mail.UserMail = Console.ReadLine();
- string m_1 = someone_mail.UserMail;
- Sendmail Some_mail = new Sendmail();
- Some_mail.SomeMail = Console.ReadLine();
- string sm = Some_mail.SomeMail;
- Sendmail my_password = new Sendmail();
- my_password.Password = null;
- while (true)
- {
- ConsoleKeyInfo i = Console.ReadKey(true);
- if (i.Key == ConsoleKey.Enter)
- {
- break;
- }
- else if (i.Key == ConsoleKey.Backspace)
- {
- if (my_password.Password.Length > 0)
- {
- my_password.Password = my_password.Password.Remove(my_password.Password.Length - 1);
- Console.Write("\b \b");
- }
- }
- else
- {
- my_password.Password += i.KeyChar;
- Console.Write("*");
- }
- }
- string pas = my_password.Password;
- Sendmail hd = new Sendmail();
- hd.Headline = "Testing";
- string h = hd.Headline;
- Sendmail some_mail = new Sendmail(m_1, sm, pas, h);
- some_mail.Print();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement