Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void SendMail(string from, string to, string subject, string message)
- {
- MailMessage mMailMessage = new MailMessage();
- // Set the sender address of the mail message
- mMailMessage.From = new MailAddress(from);
- // Set the recepient address of the mail message
- mMailMessage.To.Add(new MailAddress(to));
- // Set the subject of the mail message
- mMailMessage.Subject = subject;
- // Set the body of the mail message
- mMailMessage.Body = message;
- // Set the format of the mail message body as HTML
- mMailMessage.IsBodyHtml = false;
- // Set the priority of the mail message to normal
- mMailMessage.Priority = MailPriority.Normal;
- // Instantiate a new instance of SmtpClient
- SmtpClient mSmtpClient = new SmtpClient();
- // Send the mail message
- mSmtpClient.Credentials = new NetworkCredential("USERNAME", "PASSWORD");
- mSmtpClient.Host = "127.0.0.1";
- mSmtpClient.Send(mMailMessage);
- mMailMessage.Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement