Advertisement
Guest User

Sending my email

a guest
Sep 2nd, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Mail;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ConsoleApplication6
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             try
  16.             {
  17.                 MailMessage message = new MailMessage();
  18.                 SmtpClient smtp = new SmtpClient();
  19.  
  20.                 message.From = new MailAddress("letmelearn11@gmail.com");
  21.                 message.To.Add(new MailAddress("amitziv99@gmail.com"));
  22.                 message.Subject = "Subject 199";
  23.                 message.Body = "hello askkskksksks";
  24.  
  25.                 smtp.Port = 587;
  26.                 smtp.Host = "smtp.gmail.com";
  27.                 smtp.EnableSsl = true;
  28.                 smtp.UseDefaultCredentials = false;
  29.                 smtp.Credentials = new NetworkCredential("letmelearn11@gmail.com", "thepassword");
  30.                 smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
  31.                 smtp.Send(message);
  32.             }
  33.             catch (Exception ex)
  34.             {
  35.                 Console.WriteLine("err: " + ex.Message);
  36.             }
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement