Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
5,305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Mail; // HERE!
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace MyMail
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             SmtpClient client = new SmtpClient();
  15.             client.Port = 587;
  16.             client.DeliveryMethod = SmtpDeliveryMethod.Network;
  17.             client.UseDefaultCredentials = false;
  18.             client.Credentials = new System.Net.NetworkCredential("yaroslaw@live.ru", "pass");
  19.             client.Host = "smtp.live.com";
  20.             client.EnableSsl = true;
  21.  
  22.             MailMessage mail = new MailMessage("yaroslaw@live.ru", "knitershift@gmail.com");
  23.             mail.Subject = "this is a test email.";
  24.             mail.Body = "this is my test email body";
  25.  
  26.             client.Send(mail);
  27.  
  28.             //var mail = new MailMessage();
  29.             //mail.From = new MailAddress("youremail@hotmail.com");
  30.             //mail.To.Add("to@gmail.com");
  31.             //mail.Subject = "Test Mail - 1";
  32.             //mail.IsBodyHtml = true;
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement