Advertisement
Guest User

c# gmail

a guest
Mar 17th, 2015
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Net.Mail;
  3.  
  4. namespace Send_Mail
  5. {
  6.     class Program
  7.     {
  8.         static void Main()
  9.         {
  10.             //Set variables accordingly
  11.             string receiver_Mail = "receiver@example.com", sender_Mail = "sender@gmail.com", sender_Password = "123";
  12.  
  13.             SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
  14.             client.EnableSsl = true;
  15.             client.Credentials = new System.Net.NetworkCredential(sender_Mail, sender_Password);
  16.  
  17.             client.Send(sender_Mail, receiver_Mail, "subject", "body"); // Set the subject and body of your email
  18.  
  19.             Console.ReadLine();
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement