Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Credentials
- var credentials = new NetworkCredential("someEmail@gmail.com", "somePassword");
- // Mail message
- var mail = new MailMessage()
- {
- From = new MailAddress("someEmail@gmail.com"),
- Subject = "Test email.",
- Body = "Test email body"
- };
- mail.To.Add(new MailAddress("someEmail@gmail.com"));
- // Smtp client
- var client = new SmtpClient()
- {
- Port = 587,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- UseDefaultCredentials = false,
- Host = "smtp.gmail.com",
- EnableSsl = true,
- Credentials = credentials
- };
- // Send it...
- client.Send(mail);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement