- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Net.Mail;
- using System.Net;
- namespace smtp_client
- {
- class Program
- {
- static void Main (string[] args)
- {
- MailAddress myemail = new MailAddress("me@gmail.com", "Name");
- MailAddress mail_to = new MailAddress("receiver@yahoo.com", "Receiver");
- string password = "email_password";
- SmtpClient Client_smtp = new SmtpClient("smtp.gmail.com", 587);
- client_smtp.EnableSsl = true;
- client_smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
- client_smtp.UseDefaultCredentials = false;
- client_smtp.Credentials = new NetworkCredential (myemail.Address, password);
- MailMessage message = new MailMessage (myemail, mail_to);
- message.Subject = "Hello from sharpcode";
- message.Body = "just a test";
- client_smtp.Send(message);
- }
- }
- }