Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C# how to send email?
- new SmtpClient("smtp.server.com", 25).Send("test@hotmail.com",
- "test@gmail.com",
- "subject",
- "body");
- MailMessage mailMsg = new MailMessage();
- mailMsg.To.Add("test@hotmail.com");
- // From
- MailAddress mailAddress = new MailAddress("you@hotmail.com");
- mailMsg.From = mailAddress;
- // Subject and Body
- mailMsg.Subject = "subject";
- mailMsg.Body = "body";
- // Init SmtpClient and send on port 587 in my case. (Usual=port25)
- SmtpClient smtpClient = new SmtpClient("mailserver", Convert.ToInt32("587"));
- System.Net.NetworkCredential credentials =
- new System.Net.NetworkCredential("username", "password");
- smtpClient.Credentials = credentials;
- smtpClient.Send(mailMsg);
Add Comment
Please, Sign In to add comment