Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MailAddress from = new MailAddress("somemail@gmail.com", "Y");
- MailAddress to = new MailAddress("some@mail.ru");
- MailMessage m = new MailMessage(from, to);
- m.Subject = "Тест";
- m.Body = "<h2>Письмо</h2>";
- m.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient("localhost");
- smtp.EnableSsl = true;
- try
- {
- smtp.Send(m);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- Console.Read();
- SmtpClient client = new SmtpClient();
- client.Port = 587;
- client.Host = "smtp.gmail.com";
- client.EnableSsl = true;
- client.Timeout = 10000;
- client.DeliveryMethod = SmtpDeliveryMethod.Network;
- client.UseDefaultCredentials = false;
- client.Credentials = new System.Net.NetworkCredential("user@gmail.com","password");
- MailMessage mm = new MailMessage("donotreply@domain.com", "sendtomyemail@domain.co.uk", "test", "test");
- mm.BodyEncoding = UTF8Encoding.UTF8;
- mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
- client.Send(mm);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement